-
Notifications
You must be signed in to change notification settings - Fork 7
/
test-vine-task-throughput.c
75 lines (65 loc) · 1.62 KB
/
test-vine-task-throughput.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "taskvine.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <time.h>
#include <assert.h>
int main(int argc, char *argv[])
{
struct vine_manager *m;
int i;
int tasksC = 5000;
m = vine_create(VINE_DEFAULT_PORT);
if(!m) {
printf("couldn't create manager: %s\n", strerror(errno));
return 1;
}
printf("TaskVine listening on %d\n", vine_port(m));
for(i=0;i<tasksC;i++) {
struct vine_task *t = vine_task_create(":");
vine_task_set_cores(t, 1);
int task_id = vine_submit(m, t);
}
bool start_timer = true;
clock_t start = 0;
while(!vine_empty(m)) {
struct vine_task *t = vine_wait(m, 5);
if (start_timer){
start = clock();
start_timer = false;
}
if(t) {
vine_task_delete(t);
}
}
clock_t end = clock();
double throughtput_time = ((double)(end - start)) / CLOCKS_PER_SEC;
double throughput = tasksC / throughtput_time;
start_timer = true;
start = 0;
for(i=0;i<tasksC;i++) {
struct vine_task *t = vine_task_create(":");
vine_task_set_cores(t, 1);
if (start_timer){
start = clock();
start_timer = false;
}
int task_id = vine_submit(m, t);
while(!vine_empty(m)) {
t = vine_wait(m, 5);
if(t) {
vine_task_delete(t);
}
}
}
end = clock();
double chaining_time = ((double)(end - start)) / CLOCKS_PER_SEC;
double chaining = tasksC / chaining_time;
printf("Throughput was %f tasks per second\n", throughput);
printf("Chaining was %f tasks per second\n", chaining);
printf("all tasks complete!\n");
vine_delete(m);
return 0;
}