void speed_ed25519() { unsigned long long t[NTIMINGS]; int i; unsigned char pk[32]; unsigned char sk[64]; // Benchmarking keypair for(i=0;i<NTIMINGS;i++) { t[i] = cpucycles(); crypto_sign_keypair(pk, sk); } print_bench("sign_keypair",t,NTIMINGS); // Benchmarking sign for(i=0;i<NTIMINGS;i++) { t[i] = cpucycles(); crypto_sign(sm, &smlen, msg, MLEN, sk); } print_bench("sign (59 bytes)",t,NTIMINGS); // Benchmarking sign_open for(i=0;i<NTIMINGS;i++) { t[i] = cpucycles(); crypto_sign_open(mo, &mlen, sm, smlen, pk); } print_bench("sign_open (59 bytes)",t,NTIMINGS); }
int main(int argc, char *argv[]) { int ret = 0; int i; if( argc > 1 && !strncmp( argv[1], "--bench", 7 ) ) { #if !defined(ARCH_X86) && !defined(ARCH_X86_64) fprintf( stderr, "no --bench for your cpu until you port rdtsc\n" ); return 1; #endif do_bench = 1; if( argv[1][7] == '=' ) { bench_pattern = argv[1]+8; bench_pattern_len = strlen(bench_pattern); } argc--; argv++; } i = ( argc > 1 ) ? atoi(argv[1]) : x264_mdate(); fprintf( stderr, "x264: using random seed %u\n", i ); srand( i ); buf1 = x264_malloc( 0x3e00 + 16*BENCH_ALIGNS ); buf2 = buf1 + 0xf00; buf3 = buf2 + 0xf00; buf4 = buf3 + 0x1000; for( i=0; i<0x1e00; i++ ) buf1[i] = rand() & 0xFF; memset( buf1+0x1e00, 0, 0x2000 ); /* 16-byte alignment is guaranteed whenever it's useful, but some functions also vary in speed depending on %64 */ if( do_bench ) for( i=0; i<BENCH_ALIGNS && !ret; i++ ) { buf2 = buf1 + 0xf00; buf3 = buf2 + 0xf00; buf4 = buf3 + 0x1000; ret |= x264_stack_pagealign( check_all_flags, i*16 ); buf1 += 16; quiet = 1; fprintf( stderr, "%d/%d\r", i+1, BENCH_ALIGNS ); } else ret = check_all_flags(); if( ret ) { fprintf( stderr, "x264: at least one test has failed. Go and fix that Right Now!\n" ); return -1; } fprintf( stderr, "x264: All tests passed Yeah :)\n" ); if( do_bench ) print_bench(); return 0; }
void speed_nothing() { unsigned long long t[NTIMINGS]; int i; // Benchmarking scalarmult_base for(i=0;i<NTIMINGS;i++) t[i] = cpucycles(); print_bench("nothing",t,NTIMINGS); }
void speed_poly1305() { unsigned long long t[NTIMINGS]; unsigned char m[1024]; unsigned char out[16]; int i; for(i=0;i<NTIMINGS;i++) { t[i] = cpucycles(); crypto_onetimeauth(out,m,8,key); } print_bench("poly1305 (8 bytes)",t,NTIMINGS); for(i=0;i<NTIMINGS;i++) { t[i] = cpucycles(); crypto_onetimeauth(out,m,64,key); } print_bench("poly1305 (64 bytes)",t,NTIMINGS); for(i=0;i<NTIMINGS;i++) { t[i] = cpucycles(); crypto_onetimeauth(out,m,576,key); } print_bench("poly1305 (576 bytes)",t,NTIMINGS); for(i=0;i<NTIMINGS;i++) { t[i] = cpucycles(); crypto_onetimeauth(out,m,1024,key); } print_bench("poly1305 (1024 bytes)",t,NTIMINGS); for(i=0;i<NTIMINGS;i++) { t[i] = cpucycles(); crypto_onetimeauth(out,m,2048,key); } print_bench("poly1305 (2048 bytes)",t,NTIMINGS); }
void bench_allocators(Iter begin, std::size_t n) { // The different sets we will benchmark. typedef Set<int, std::less<int>, std::allocator<int>> set_type1; typedef Set<int, std::less<int>, rt::node_allocator<int>> set_type2; // Uses a vector as buffer. typedef Set<int, std::less<int>, __gnu_cxx::__pool_alloc<int>> set_type3; typedef Set<int, std::less<int>, __gnu_cxx::bitmap_allocator<int>> set_type4; typedef Set<int, std::less<int>, __gnu_cxx::__mt_alloc<int>> set_type5; #ifdef Boost_FOUND typedef Set<int, std::less<int>, boost::container::node_allocator<int, 100000, 1>> set_type6; typedef Set<int, std::less<int>, boost::container::node_allocator<int, 100000, 2>> set_type7; #endif std::cout << n << " "; { // (1) set_type1 s; print_bench(s, begin, n); } { // (2) std::vector<char> buffer((n + 2) * 40, 0); rt::node_allocator<int> alloc(buffer); set_type2 s(std::less<int>(), alloc); // Uses a vector as buffer. print_bench(s, begin, n); } { // (3) set_type3 s; print_bench(s, begin, n); } { // (4) set_type4 s; print_bench(s, begin, n); } { // (5) set_type5 s; print_bench(s, begin, n); } #ifdef Boost_FOUND { // (6) set_type6 s; print_bench(s, begin, n); } { // (7) set_type7 s; print_bench(s, begin, n); } #endif }