]>
git.saurik.com Git - apple/libdispatch.git/blob - testing/fork-join.c
   2 #include <mach/mach_time.h> 
   3 #include <dispatch/dispatch.h> 
   4 #include <dispatch/private.h> 
  12         long double nano_per_lap
; 
  13         size_t i
, cnt 
= 1000000; 
  14         dispatch_future_t 
*df
; 
  17         df 
= malloc(cnt 
* sizeof(df
)); 
  20         s 
= mach_absolute_time(); 
  22         for (i 
= 0; i 
< cnt
; i
++) { 
  23                 df
[i
] = dispatch_fork(dispatch_get_concurrent_queue(0), ^{ 
  28         for (i 
= 0; i 
< cnt
; i
++) { 
  32         e 
= mach_absolute_time(); 
  34         nano_per_lap 
= (e 
- s
); 
  37         printf("%Lf nanoseconds per lap\n", nano_per_lap
);