]>
git.saurik.com Git - apple/libdispatch.git/blob - testing/dispatch_cascade.c
2 #include <dispatch/dispatch.h>
6 #include "dispatch_test.h"
11 dispatch_queue_t queues
[QUEUES
];
20 size_t iterations
= QUEUES
* BLOCKS
* 0.25;
24 size_t counts
[QUEUES
] = {};
28 for (q
= 0; q
< QUEUES
; ++q
) {
30 for (i
= 0; i
< BLOCKS
; ++i
) {
31 if (indices
[i
].index
== q
) {
37 for (q
= 0; q
< QUEUES
; ++q
) {
38 if (counts
[q
] > maxcount
) {
43 printf("maxcount = %ld\n", maxcount
);
46 for (y
= 20; y
> 0; --y
) {
47 for (x
= 0; x
< QUEUES
; ++x
) {
48 double fraction
= (double)counts
[x
] / (double)maxcount
;
49 double value
= fraction
* (double)20;
50 printf("%s", (value
> y
) ? "*" : " ");
57 cascade(void* context
) {
58 size_t idx
, *idxptr
= context
;
66 dispatch_async_f(queues
[idx
], context
, cascade
);
69 if (__sync_sub_and_fetch(&iterations
, 1) == 0) {
78 main(int argc
__attribute__((unused
)), char* argv
[] __attribute__((unused
))) {
81 test_start("Dispatch Cascade");
83 for (i
= 0; i
< QUEUES
; ++i
) {
84 queues
[i
] = dispatch_queue_create(NULL
, NULL
);
87 for (i
= 0; i
< BLOCKS
; ++i
) {
88 cascade(&indices
[i
].index
);