#include #include #include #include typedef struct { int i; int loops; } shared; void worker( void *arg ) { shared *s = (shared*)arg; int i = 0; for( i=0; i < s->loops; ++i ) { ++s->i; } return; } void main( int argc, char **argv ) { int i = = 0, nThreads = 4; clock_t start, finish; double elapsed; uintptr_t threads[32]; shared s = { 0, 1000000 };; if( argc > 1 ) nThreads = atol( argv[1] ); if( argc > 2 ) s.loops = atol( argv[2] ); printf( "threads:%d loops:%d\n", nThreads, s.loops ); start = clock(); for( i=0; i < nThreads; ++i ) threads[ i ] = _beginthread( &worker, 0, &s ); bit ) ) ? 1 : 0; } U64 clrbit( SV *self, SV *offset ) { U64 *vec = (U64*)SvPVX( SvRV( self ) ); U64 bit = Sv #include UV( offset ) WaitForMultipleObjects( nThreads, (HANDLE*)&threads, 1, INFINITE ); finish = clock(); elapsed = (double)(finish - start) / CLOCKS_PER_SEC; printf( "count: %lu time:%.6f\n", s.i, elapsed ); }