int main(int argc, char **argv) { double elapsed_time = 0; u_int32_t num_tests = 3000000; argc = argc; argv = argv; printf("mutex is %d bytes\n", sizeof(pthread_mutex_t)); printf("default:\n"); time_it(NULL, &elapsed_time, num_tests); printf("%.3f seconds\n", elapsed_time); printf("\n"); fflush(stdout); printf("hash_func1:\n"); time_it(hash_func1, &elapsed_time, num_tests); printf("%.3f seconds\n", elapsed_time); printf("\n"); fflush(stdout); printf("hash_func_tc:\n"); time_it(hash_func_tc, &elapsed_time, num_tests); printf("%.3f seconds\n", elapsed_time); printf("\n"); fflush(stdout); return 1; }
int main() { long value = 600851475143; long repetitions = 70; double prime_iterative_time = time_it(value, repetitions, is_prime_iterative); double prime_faster_time = time_it(value, repetitions, is_prime_faster); double gpf1_time = time_it(value, repetitions, find_greatest_prime_factor_1); double gpf2_time = time_it(value, repetitions, find_greatest_prime_factor_2); double prime_iterative_average = prime_iterative_time / repetitions; double prime_faster_average = prime_faster_time / repetitions; double gpf1_average = gpf1_time / repetitions; double gpf2_average = gpf2_time / repetitions; printf("\n===========================================================\n\n"); printf("-------------------------------------------\n"); printf("Execution time for is prime algorithms\n"); printf("n = %ld\n", value); printf("repetitions = %ld\n", repetitions); printf("-------------------------------------------\n\n"); printf("Total:\n"); printf("is_prime_iterative: %f\n", prime_iterative_time); printf("is_prime_faster: %f\n", prime_faster_time); printf("Average:\n"); printf("is_prime_iterative: %f\n", prime_iterative_average); printf("is_prime_faster: %f\n", prime_faster_average); printf("\n\n"); printf("-------------------------------------------\n"); printf("Execution time find greatest prime factor algorithms\n"); printf("n = %ld\n", value); printf("repetitions = %ld\n", repetitions); printf("-------------------------------------------\n\n"); printf("Total:\n"); printf("gpf1: %f\n", gpf1_time); printf("gpf2: %f\n", gpf2_time); printf("Average:\n"); printf("gpf1: %f\n", gpf1_average); printf("gpf2: %f\n", gpf2_average); printf("\n\n"); printf("===========================================================\n\n"); }
int main() { boost::filesystem::current_path(base::path::self().remove_filename()); time_it(benchmark_1); time_it(benchmark_2); system("pause"); return 0; }
char *test_performance() { init_timer(); time_it(rm_lifecycle, "RadixMap lyfecycle"); return NULL; }
static std::vector<double> time() { std::vector<double> results; for (int i = 0; i < test_times; ++i) { const auto t = Derived::rand_test_case(); I r; const double trial = time_it([&] { Derived::calc(r, t.first, t.second); }); results.push_back(trial); Derived::check(r, t.first, t.second); } return results; }
main(void) { show_it(time_it(t_printf)); printf(": time for text printf buffered\n"); show_it(time_it(b_printf)); printf(": time for binary printf buffered\n"); show_it(time_it(tu_printf)); printf(": time for text printf unbuffered\n"); show_it(time_it(bu_printf)); printf(": time for binary printf unbuffered\n"); show_it(time_it(t_write)); printf(": time for text write buffered\n"); show_it(time_it(b_write)); printf(": time for binary write buffered\n"); show_it(time_it(tu_write)); printf(": time for text write unbuffered\n"); show_it(time_it(bu_write)); printf(": time for binary write unbuffered\n"); return 0; }
int main() { int i, j, k, z, lenmax; char buf[BUFLEN]; FILE *out; double thetime; lenmax = get_the_longest(datlengths); printf("Bigger data set has %d elements\n", lenmax); tobesorted = malloc(sizeof(double)*lenmax); if ( tobesorted == NULL ) return 1; setfillconst(1.0); for(i=0; testpieces[i].name != NULL; i++) { for(j=0; seqdefs[j].name != NULL; j++) { snprintf(buf, BUFLEN, filetempl, bname, testpieces[i].name, seqdefs[j].name); out = fopen(buf, "w"); if ( out == NULL ) goto severe; printf("Producing data for sort '%s', created data type '%s'\n", testpieces[i].name, seqdefs[j].name); for(k=0; datlengths[k] > 0; k++) { printf("\tNumber of elements: %d\n", datlengths[k]); thetime = 0.0; seqdefs[j].seqcreator(tobesorted, datlengths[k]); fprintf(out, "%d ", datlengths[k]); for(z=0; z < MEANREPEAT; z++) { thetime += time_it(testpieces[i].action, datlengths[k]); } thetime /= MEANREPEAT; fprintf(out, "%.8lf\n", thetime); } fclose(out); } } severe: free(tobesorted); return 0; }
int main() { printf("identity (4) takes %lf s\n", time_it(identity, 4)); printf("sum (4) takes %lf s\n", time_it(sum, 4)); return 0; }
int main(int argc, char **argv) { long count; static unsigned char buf[BUFSIZE]; static char key[16]={ 0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0, 0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0}; BF_KEY sch; double d,tm[16],max=0; int rank[16]; char *str[16]; int max_idx=0,i,num=0,j; #ifndef SIGALARM long ca,cb,cc,cd,ce; #endif for (i=0; i<12; i++) { tm[i]=0.0; rank[i]=0; } #ifndef TIMES fprintf(stderr,"To get the most accurate results, try to run this\n"); fprintf(stderr,"program when this computer is idle.\n"); #endif BF_set_key(&sch,16,key); #ifndef SIGALRM fprintf(stderr,"First we calculate the approximate speed ...\n"); count=10; do { long i; unsigned long data[2]; count*=2; Time_F(START); for (i=count; i; i--) BF_encrypt(data,&sch); d=Time_F(STOP); } while (d < 3.0); ca=count; cb=count*3; cc=count*3*8/BUFSIZE+1; cd=count*8/BUFSIZE+1; ce=count/20+1; #define COND(d) (count != (d)) #define COUNT(d) (d) #else #define COND(c) (run) #define COUNT(d) (count) signal(SIGALRM,sig_done); alarm(10); #endif time_it(BF_encrypt_normal, "BF_encrypt_normal ", 0); time_it(BF_encrypt_ptr, "BF_encrypt_ptr ", 1); time_it(BF_encrypt_ptr2, "BF_encrypt_ptr2 ", 2); num+=3; str[0]="<nothing>"; print_it("BF_encrypt_normal ",0); max=tm[0]; max_idx=0; str[1]="ptr "; print_it("BF_encrypt_ptr ",1); if (max < tm[1]) { max=tm[1]; max_idx=1; } str[2]="ptr2 "; print_it("BF_encrypt_ptr2 ",2); if (max < tm[2]) { max=tm[2]; max_idx=2; } printf("options BF ecb/s\n"); printf("%s %12.2f 100.0%%\n",str[max_idx],tm[max_idx]); d=tm[max_idx]; tm[max_idx]= -2.0; max= -1.0; for (;;) { for (i=0; i<3; i++) { if (max < tm[i]) { max=tm[i]; j=i; } } if (max < 0.0) break; printf("%s %12.2f %4.1f%%\n",str[j],tm[j],tm[j]/d*100.0); tm[j]= -2.0; max= -1.0; } switch (max_idx) { case 0: printf("-DBF_DEFAULT_OPTIONS\n"); break; case 1: printf("-DBF_PTR\n"); break; case 2: printf("-DBF_PTR2\n"); break; } exit(0); #if defined(LINT) || defined(OPENSSL_SYS_MSDOS) return(0); #endif }
int main(int argc, char **argv) { long count; static unsigned char buf[BUFSIZE]; static DES_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0}; static DES_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12}; static DES_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34}; DES_key_schedule sch,sch2,sch3; double d,tm[16],max=0; int rank[16]; char *str[16]; int max_idx=0,i,num=0,j; #ifndef SIGALARM long ca,cb,cc,cd,ce; #endif for (i=0; i<12; i++) { tm[i]=0.0; rank[i]=0; } #ifndef TIMES TINYCLR_SSL_FPRINTF(OPENSSL_TYPE__FILE_STDERR,"To get the most accurate results, try to run this\n"); TINYCLR_SSL_FPRINTF(OPENSSL_TYPE__FILE_STDERR,"program when this computer is idle.\n"); #endif DES_set_key_unchecked(&key,&sch); DES_set_key_unchecked(&key2,&sch2); DES_set_key_unchecked(&key3,&sch3); #ifndef SIGALRM TINYCLR_SSL_FPRINTF(OPENSSL_TYPE__FILE_STDERR,"First we calculate the approximate speed ...\n"); DES_set_key_unchecked(&key,sch); count=10; do { long i; unsigned long data[2]; count*=2; Time_F(START); for (i=count; i; i--) DES_encrypt1(data,&(sch[0]),DES_ENCRYPT); d=Time_F(STOP); } while (d < 3.0); ca=count; cb=count*3; cc=count*3*8/BUFSIZE+1; cd=count*8/BUFSIZE+1; ce=count/20+1; #define COND(d) (count != (d)) #define COUNT(d) (d) #else #define COND(c) (run) #define COUNT(d) (count) signal(SIGALRM,sig_done); alarm(10); #endif #ifdef PART1 time_it(des_encrypt_u4_cisc_idx, "des_encrypt_u4_cisc_idx ", 0); time_it(des_encrypt_u16_cisc_idx, "des_encrypt_u16_cisc_idx ", 1); time_it(des_encrypt_u4_risc1_idx, "des_encrypt_u4_risc1_idx ", 2); num+=3; #endif #ifdef PART2 time_it(des_encrypt_u16_risc1_idx,"des_encrypt_u16_risc1_idx", 3); time_it(des_encrypt_u4_risc2_idx, "des_encrypt_u4_risc2_idx ", 4); time_it(des_encrypt_u16_risc2_idx,"des_encrypt_u16_risc2_idx", 5); num+=3; #endif #ifdef PART3 time_it(des_encrypt_u4_cisc_ptr, "des_encrypt_u4_cisc_ptr ", 6); time_it(des_encrypt_u16_cisc_ptr, "des_encrypt_u16_cisc_ptr ", 7); time_it(des_encrypt_u4_risc1_ptr, "des_encrypt_u4_risc1_ptr ", 8); num+=3; #endif #ifdef PART4 time_it(des_encrypt_u16_risc1_ptr,"des_encrypt_u16_risc1_ptr", 9); time_it(des_encrypt_u4_risc2_ptr, "des_encrypt_u4_risc2_ptr ",10); time_it(des_encrypt_u16_risc2_ptr,"des_encrypt_u16_risc2_ptr",11); num+=3; #endif #ifdef PART1 str[0]=" 4 c i"; print_it("des_encrypt_u4_cisc_idx ",0); max=tm[0]; max_idx=0; str[1]="16 c i"; print_it("des_encrypt_u16_cisc_idx ",1); if (max < tm[1]) { max=tm[1]; max_idx=1; } str[2]=" 4 r1 i"; print_it("des_encrypt_u4_risc1_idx ",2); if (max < tm[2]) { max=tm[2]; max_idx=2; } #endif #ifdef PART2 str[3]="16 r1 i"; print_it("des_encrypt_u16_risc1_idx",3); if (max < tm[3]) { max=tm[3]; max_idx=3; } str[4]=" 4 r2 i"; print_it("des_encrypt_u4_risc2_idx ",4); if (max < tm[4]) { max=tm[4]; max_idx=4; } str[5]="16 r2 i"; print_it("des_encrypt_u16_risc2_idx",5); if (max < tm[5]) { max=tm[5]; max_idx=5; } #endif #ifdef PART3 str[6]=" 4 c p"; print_it("des_encrypt_u4_cisc_ptr ",6); if (max < tm[6]) { max=tm[6]; max_idx=6; } str[7]="16 c p"; print_it("des_encrypt_u16_cisc_ptr ",7); if (max < tm[7]) { max=tm[7]; max_idx=7; } str[8]=" 4 r1 p"; print_it("des_encrypt_u4_risc1_ptr ",8); if (max < tm[8]) { max=tm[8]; max_idx=8; } #endif #ifdef PART4 str[9]="16 r1 p"; print_it("des_encrypt_u16_risc1_ptr",9); if (max < tm[9]) { max=tm[9]; max_idx=9; } str[10]=" 4 r2 p"; print_it("des_encrypt_u4_risc2_ptr ",10); if (max < tm[10]) { max=tm[10]; max_idx=10; } str[11]="16 r2 p"; print_it("des_encrypt_u16_risc2_ptr",11); if (max < tm[11]) { max=tm[11]; max_idx=11; } #endif TINYCLR_SSL_PRINTF("options des ecb/s\n"); TINYCLR_SSL_PRINTF("%s %12.2f 100.0%%\n",str[max_idx],tm[max_idx]); d=tm[max_idx]; tm[max_idx]= -2.0; max= -1.0; for (;;) { for (i=0; i<12; i++) { if (max < tm[i]) { max=tm[i]; j=i; } } if (max < 0.0) break; TINYCLR_SSL_PRINTF("%s %12.2f %4.1f%%\n",str[j],tm[j],tm[j]/d*100.0); tm[j]= -2.0; max= -1.0; } switch (max_idx) { case 0: TINYCLR_SSL_PRINTF("-DDES_DEFAULT_OPTIONS\n"); break; case 1: TINYCLR_SSL_PRINTF("-DDES_UNROLL\n"); break; case 2: TINYCLR_SSL_PRINTF("-DDES_RISC1\n"); break; case 3: TINYCLR_SSL_PRINTF("-DDES_UNROLL -DDES_RISC1\n"); break; case 4: TINYCLR_SSL_PRINTF("-DDES_RISC2\n"); break; case 5: TINYCLR_SSL_PRINTF("-DDES_UNROLL -DDES_RISC2\n"); break; case 6: TINYCLR_SSL_PRINTF("-DDES_PTR\n"); break; case 7: TINYCLR_SSL_PRINTF("-DDES_UNROLL -DDES_PTR\n"); break; case 8: TINYCLR_SSL_PRINTF("-DDES_RISC1 -DDES_PTR\n"); break; case 9: TINYCLR_SSL_PRINTF("-DDES_UNROLL -DDES_RISC1 -DDES_PTR\n"); break; case 10: TINYCLR_SSL_PRINTF("-DDES_RISC2 -DDES_PTR\n"); break; case 11: TINYCLR_SSL_PRINTF("-DDES_UNROLL -DDES_RISC2 -DDES_PTR\n"); break; } TINYCLR_SSL_EXIT(0); #if defined(LINT) || defined(OPENSSL_SYS_MSDOS) return(0); #endif }
// Tests the performance of the fibonacci and fibonacci2 functions. int main() { auto t1 = time_it(fibonacci, 50); auto t2 = time_it(fibonacci2, 50); std::cout << "Time: " << "fibonacci = "<< t1 << " msec, fibonacci2 = " << t2 << " msec\n"; }
double speedup(std::function<void ()> serial, std::function<void ()> parallel) { double s = time_it(serial); double p = time_it(parallel); return s / p; }