int main (int argc, char ** argv) { stinger_t * S = stinger_new(); /* insert your data now */ load_benchmark_data_into_stinger (S, argv[1],0); /* get number of vertices */ uint64_t nv = stinger_max_active_vertex (S); nv++; print_fragmentation_stats (S, nv); /* auxiliary data structure */ double * pagerank_scores = xmalloc (nv * sizeof(int64_t)); double * pagerank_scores_tmp = xmalloc (nv * sizeof(int64_t)); /* the algorithm itself (timed) */ bench_start(); pagerank (S, nv, pagerank_scores, pagerank_scores_tmp, 1e-8, 0.85, 100); bench_end(); printf("Done.\n"); /* cleanup */ free (pagerank_scores); free (pagerank_scores_tmp); stinger_free_all (S); return 0; }
void edit_typeset_rep::typeset_sub (SI& x1, SI& y1, SI& x2, SI& y2) { //time_t t1= texmacs_time (); typeset_prepare (); eb= empty_box (reverse (rp)); // saves memory, also necessary for change_log update bench_start ("typeset"); #ifdef USE_EXCEPTIONS try { #endif eb= ::typeset (ttt, x1, y1, x2, y2); #ifdef USE_EXCEPTIONS } catch (string msg) { the_exception= msg; std_error << "Typesetting failure, resetting to empty document\n"; assign (rp, tree (DOCUMENT, "")); ::notify_assign (ttt, path(), subtree (et, rp)); eb= ::typeset (ttt, x1, y1, x2, y2); } handle_exceptions (); #endif bench_end ("typeset"); //time_t t2= texmacs_time (); //if (t2 - t1 >= 10) cout << "typeset took " << t2-t1 << "ms\n"; picture_cache_clean (); }
// evaluate cost of a simple as possible system call void bench_syscall(void) { uint64_t t0, t1; int i; t0 = bench_start(); for (i = 0; i < N; i++) { syscall(SYS_getpid); } t1 = bench_end(); printf("System call (getpid): %" PRIu64 " cycles\n", (t1 - t0 - tsc_overhead) / N); }
// measure the cost to call `clock_gettime` for the specified clock uint64_t clock_overhead() { int i; struct timespec t; uint64_t t0, t1, overhead = ~0; // we run N times and take the min for (i = 0; i < N; i++) { t0 = bench_start(); clock_gettime(CLOCK, &t); t1 = bench_end(); if (t1 - t0 < overhead) overhead = t1 - t0; } return overhead - tsc_overhead; }
int main(){ bench_start(); int result = tarai(12,6,0); bench_end(); }
static double bench(const LilvPlugin* p, uint32_t sample_count, uint32_t block_size) { URITable uri_table; uri_table_init(&uri_table); LV2_URID_Map map = { &uri_table, uri_table_map }; LV2_Feature map_feature = { LV2_URID_MAP_URI, &map }; LV2_URID_Unmap unmap = { &uri_table, uri_table_unmap }; LV2_Feature unmap_feature = { LV2_URID_UNMAP_URI, &unmap }; const LV2_Feature* features[] = { &map_feature, &unmap_feature, NULL }; float* const buf = (float*)calloc(block_size * 2, sizeof(float)); float* const in = buf; float* const out = buf + block_size; if (!buf) { fprintf(stderr, "Out of memory\n"); return 0.0; } LV2_Atom_Sequence seq = { { sizeof(LV2_Atom_Sequence_Body), uri_table_map(&uri_table, LV2_ATOM__Sequence) }, { 0, 0 } }; const char* uri = lilv_node_as_string(lilv_plugin_get_uri(p)); LilvNodes* required = lilv_plugin_get_required_features(p); LILV_FOREACH(nodes, i, required) { const LilvNode* feature = lilv_nodes_get(required, i); if (!lilv_node_equals(feature, urid_map)) { fprintf(stderr, "<%s> requires feature <%s>, skipping\n", uri, lilv_node_as_uri(feature)); free(buf); uri_table_destroy(&uri_table); return 0.0; } } LilvInstance* instance = lilv_plugin_instantiate(p, 48000.0, features); if (!instance) { fprintf(stderr, "Failed to instantiate <%s>\n", lilv_node_as_uri(lilv_plugin_get_uri(p))); free(buf); uri_table_destroy(&uri_table); return 0.0; } float* controls = (float*)calloc( lilv_plugin_get_num_ports(p), sizeof(float)); lilv_plugin_get_port_ranges_float(p, NULL, NULL, controls); const uint32_t n_ports = lilv_plugin_get_num_ports(p); for (uint32_t index = 0; index < n_ports; ++index) { const LilvPort* port = lilv_plugin_get_port_by_index(p, index); if (lilv_port_is_a(p, port, lv2_ControlPort)) { lilv_instance_connect_port(instance, index, &controls[index]); } else if (lilv_port_is_a(p, port, lv2_AudioPort) || lilv_port_is_a(p, port, lv2_CVPort)) { if (lilv_port_is_a(p, port, lv2_InputPort)) { lilv_instance_connect_port(instance, index, in); } else if (lilv_port_is_a(p, port, lv2_OutputPort)) { lilv_instance_connect_port(instance, index, out); } else { fprintf(stderr, "<%s> port %d neither input nor output, skipping\n", uri, index); lilv_instance_free(instance); free(buf); free(controls); uri_table_destroy(&uri_table); return 0.0; } } else if (lilv_port_is_a(p, port, atom_AtomPort)) { lilv_instance_connect_port(instance, index, &seq); } else { fprintf(stderr, "<%s> port %d has unknown type, skipping\n", uri, index); lilv_instance_free(instance); free(buf); free(controls); uri_table_destroy(&uri_table); return 0.0; } } lilv_instance_activate(instance); struct timespec ts = bench_start(); for (uint32_t i = 0; i < (sample_count / block_size); ++i) { lilv_instance_run(instance, block_size); } const double elapsed = bench_end(&ts); lilv_instance_deactivate(instance); lilv_instance_free(instance); uri_table_destroy(&uri_table); if (full_output) { printf("%d %d ", block_size, sample_count); } printf("%lf %s\n", elapsed, uri); free(buf); free(controls); return elapsed; }