|
6 | 6 | #include <errno.h> |
7 | 7 | #include <unistd.h> |
8 | 8 | #include <time.h> |
9 | | - |
| 9 | +#include <assert.h> |
10 | 10 | int main(int argc, char *argv[]) |
11 | 11 | { |
12 | 12 | struct vine_manager *m; |
13 | | - struct vine_task *t; |
14 | 13 | int i; |
15 | 14 | int tasksC = 5000; |
16 | 15 |
|
17 | | - //Create the manager. All tasks and files will be declared with respect to |
18 | 16 | m = vine_create(VINE_DEFAULT_PORT); |
| 17 | + printf("%d", VINE_DEFAULT_PORT); |
19 | 18 | if(!m) { |
20 | 19 | printf("couldn't create manager: %s\n", strerror(errno)); |
21 | 20 | return 1; |
22 | 21 | } |
23 | 22 | printf("TaskVine listening on %d\n", vine_port(m)); |
24 | | - printf("Declaring tasks..."); |
25 | 23 |
|
26 | 24 | for(i=0;i<tasksC;i++) { |
27 | 25 | struct vine_task *t = vine_task_create(":"); |
28 | 26 | vine_task_set_cores(t, 1); |
| 27 | + |
29 | 28 | int task_id = vine_submit(m, t); |
30 | | - } |
31 | 29 |
|
32 | | - printf("waiting for tasks to complete...\n"); |
33 | | - clock_t start = clock(); |
| 30 | + } |
| 31 | + bool start_timer = true; |
| 32 | + clock_t start = 0; |
34 | 33 | while(!vine_empty(m)) { |
35 | | - t = vine_wait(m, 5); |
36 | | - if(t) { |
37 | | - vine_task_delete(t); |
| 34 | + struct vine_task *t = vine_wait(m, 5); |
| 35 | + if (start_timer){ |
| 36 | + start = clock(); |
| 37 | + start_timer = false; |
38 | 38 | } |
39 | | - } |
| 39 | + if(t) { |
| 40 | + vine_task_delete(t); |
| 41 | + } |
| 42 | + } |
40 | 43 | clock_t end = clock(); |
41 | | - double time = ((double)(end - start)) / CLOCKS_PER_SEC; |
42 | | - double throughput = tasksC / time; |
43 | | - printf("all tasks complete!\n"); |
44 | | - printf("Time was %f seconds\n", time); |
| 44 | + double throughtput_time = ((double)(end - start)) / CLOCKS_PER_SEC; |
| 45 | + |
| 46 | + double throughput = tasksC / throughtput_time; |
| 47 | + |
45 | 48 | printf("Throughput was %f tasks per second\n", throughput); |
46 | | - //Free the manager structure, and release all the workers. |
| 49 | + printf("all tasks complete!\n"); |
| 50 | + assert(throughput > 1000); |
47 | 51 | vine_delete(m); |
48 | 52 |
|
49 | 53 | return 0; |
|
0 commit comments