static void update_count() { time_t curr = time(NULL); text_layer_set_text(s_count_data_layer, time_between(curr, checktime)); }
void test_fft(size_t size, double time = 1.5) { const tick_value correction = 0;//calibrate_correction(); printf("> [%9ld, ", (long)size); real* in = aligned_malloc<real>(size * 2); real* out = aligned_malloc<real>(size * 2); fill_random(in, size * 2); std::copy(in, in + size * 2, out); fft_benchmark<false> fft(size, out, out); fft.execute(); fill_random(in, size * 2); std::vector<tick_value> measures; const tick_value bench_tick_start = tick(); const time_value bench_start = now(); while (time_between(now(), bench_start) < time) { const tick_value start = tick(); fft.execute(); const tick_value stop = tick(); const tick_value diff = stop - start; measures.push_back(diff >= correction ? diff - correction : 0); fill_random(in, size * 2); dont_optimize(out); std::copy(in, in + size * 2, out); } const tick_value bench_tick_stop = tick(); const time_value bench_stop = now(); const double tick_frequency = (long double)(bench_tick_stop - bench_tick_start) / time_between(bench_stop, bench_start); tick_value tick_value = get_minimum(measures); double time_value = tick_value / tick_frequency; const double flops = (5.0 * size * std::log((double)size) / (std::log(2.0) * time_value)); const char* units = "'s' "; if (time_value < 0.000001) { units = "'ns'"; time_value = time_value * 1000000000.0; } else if (time_value < 0.001) { units = "'us'"; time_value = time_value * 1000000.0; } else if (time_value < 1.0) { units = "'ms'"; time_value = time_value * 1000.0; } printf("%9lld, ", tick_value); printf("%7g, %s, ", time_value, units); printf("%7g, ", flops / 1000000.0); printf("%8lld, ", measures.size()); printf("%8.6f],\n", tick_frequency / 1000000000.0); aligned_free(in); aligned_free(out); }
/* Nanoseconds per operation */ static size_t normalize(const struct timeabs *start, const struct timeabs *stop, unsigned int num) { return time_to_nsec(time_divide(time_between(*stop, *start), num)); }