aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c48
1 files changed, 36 insertions, 12 deletions
diff --git a/main.c b/main.c
index dc5dbaf..d4f4dba 100644
--- a/main.c
+++ b/main.c
@@ -45,34 +45,57 @@ int factor(int x)
void factor_task(void *arg)
{
- printf("Task start\n");
- fflush(stdout);
- printf("Factor: %d\n", factor(42));
- fflush(stdout);
+ //printf("Task start\n");
+ //fflush(stdout);
+ //printf("Factor: %d\n", factor(42));
+ //fflush(stdout);
+ volatile int i = factor(16);
+
+ //printf("Factor: %d\n", factor(15));
}
+#include <x86intrin.h>
+
void bar()
{
bh_thread_pool_t *pool;
bh_task_t *task;
size_t i;
+
+ bh_uint64_t start, end;
- printf("Pool create\n");
- fflush(stdout);
+ //printf("Pool create\n");
+ //fflush(stdout);
pool = bh_thread_pool_new(16);
+ if (!pool)
+ {
+ //printf("Pool creation error\n");
+ return;
+ }
- printf("Prepare\n");
- fflush(stdout);
- for (i = 0; i < 32; i++)
+ //printf("Prepare\n");
+ //fflush(stdout);
+
+ start = __rdtsc();
+
+ for (i = 0; i < 128 * 1024; i++)
{
- printf("Task create\n");
- fflush(stdout);
+ //printf("Task create\n");
+ //fflush(stdout);
task = bh_task_new(factor_task, NULL, BH_THREAD_CLEANUP);
bh_thread_pool_add(pool, task);
}
+
+ //system("pause");
bh_thread_pool_wait(pool);
+ end = __rdtsc();
bh_thread_pool_free(pool);
+
+
+
+ printf("Elapsed: %llu\n", end - start);
+ //system("pause");
}
int main()
@@ -81,11 +104,12 @@ int main()
void *iter;
size_t i, j;
- foo();
+ //foo();
printf("Thread?\n");
fflush(stdout);
bar();
+ return 0;
queue = bh_queue_new();