#pragma once #include #include #include struct cluster * the_benchmark_cluster = 0p; struct BenchCluster { cluster self; }; void ?{}( BenchCluster & this, int flags ) { (this.self){ "Benchmark Cluster", flags }; assert( the_benchmark_cluster == 0p ); the_benchmark_cluster = &this.self; } struct BenchProc { processor self; }; void ?{}( BenchProc & this ) { assert( the_benchmark_cluster != 0p ); (this.self){ "Benchmark Processor", *the_benchmark_cluster }; } void wait(double duration, Time & start, Time & end, bool is_tty) { for() { sleep(500`ms); end = getTime(); if( (end - start) >= duration`s ) { break; } if(is_tty) { printf("\r%.4lf", (double)(end - start)`s); fflush(stdout); } } }