source:
benchmark/creation/pthreads.c
@
936d95c
Last change on this file since 936d95c was b4107c8, checked in by , 5 years ago | |
---|---|
|
|
File size: 517 bytes |
Rev | Line | |
---|---|---|
[034165a] | 1 | #include <pthread.h> |
2 | #include <stdio.h> | |
3 | ||
4 | #include "bench.h" | |
5 | ||
[b4107c8] | 6 | static void * foo(void *arg) { |
[034165a] | 7 | return arg; |
8 | } | |
9 | ||
[b4107c8] | 10 | int main( int argc, char * argv[] ) { |
11 | BENCH_START() | |
[034165a] | 12 | BENCH( |
[b4107c8] | 13 | for (size_t i = 0; i < times; i++) { |
[034165a] | 14 | pthread_t thread; |
15 | if (pthread_create(&thread, NULL, foo, NULL) < 0) { | |
16 | perror( "failure" ); | |
17 | return 1; | |
18 | } | |
19 | if (pthread_join( thread, NULL) < 0) { | |
20 | perror( "failure" ); | |
21 | return 1; | |
22 | } | |
23 | }, | |
24 | result | |
25 | ) | |
[b4107c8] | 26 | printf( "%g\n", result ); |
[dc33b5b] | 27 | } |
[b4107c8] | 28 | |
29 | // Local Variables: // | |
30 | // tab-width: 4 // | |
31 | // End: // |
Note: See TracBrowser
for help on using the repository browser.