Skip to content

hw2 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open

hw2 #1

wants to merge 31 commits into from

Conversation

erik770
Copy link
Owner

@erik770 erik770 commented Oct 31, 2021

No description provided.

@erik770
Copy link
Owner Author

erik770 commented Oct 31, 2021

Вариант #17
Сравните и выведите в консоль время работы последовательного и параллельного с использованием нескольких процессов алгоритмов, каждый из которых выделяет в динамической памяти символьный массив размером 100 Мб и выполняет поиск самого длинного слова в тексте. Словом считается последовательность, состоящая из букв и ограниченная пробелами.

@codecov-commenter
Copy link

codecov-commenter commented Oct 31, 2021

Codecov Report

❗ No coverage uploaded for pull request base (main@fd45eb5). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main       #1   +/-   ##
=======================================
  Coverage        ?   88.41%           
=======================================
  Files           ?        5           
  Lines           ?      233           
  Branches        ?        0           
=======================================
  Hits            ?      206           
  Misses          ?       27           
  Partials        ?        0           
Flag Coverage Δ
unittests 88.41% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fd45eb5...8180f9d. Read the comment docs.

@erik770
Copy link
Owner Author

erik770 commented Nov 2, 2021

Run ./build/stress_test && ./build/stress_test_procs
average time: 0.0286566  - with forks
average time: 0.203058  - w/o forks

Comment on lines 38 to 40
char *word = strtok(copy, " ");
if (word == NULL) {
free(copy);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ради использования strtock ты создаешь дополнительный буффер размером 100мб? А если входная строка будет 10гб?

Comment on lines 9 to 12
if (longest_word == NULL) {
free(string_of_words);
return NULL;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ты не должен удалять переданный из вне массив внутри функции

return NULL;
}

char *longest_word = (char *) malloc(strlen(string_of_words) * sizeof(char));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Создаешь второй огромный буффер?

char mtext[BUFF_SIZE];
} message_buff;

char *find_longest_word(char *string_of_words) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

функция слишком большая, разбей

Comment on lines 21 to 25
while (string_of_words[i] != ' ' && string_of_words[i] !='\0') {
current_word[j] = string_of_words[i];
i++;
j++;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше вынести в функцию принимающую char *dest, const char *src

} message_buff;


void child_procs_work(char *string_of_words, size_t current_procs_numb, size_t number_of_procs, int q_id) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

слишком длинная функция

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants