double recent_wall_time() const { if (!running) return 0; timeval now_wallclock; measure_wallclock(now_wallclock); return elapsed_sec(now_wallclock, then_wallclock); }
void routesplinesterm (void) { free (ps), ps = NULL, maxpn = pn = 0; free (bs), bs = NULL, maxbn = bn = 0; if (Verbose) fprintf (stderr, "routesplines: %d edges, %d boxes, %d splines %.2f sec\n", nedges, nboxes, nsplines,elapsed_sec()); }
double recent_system_time() const { #ifndef _WIN32 if (!running) return 0; rusage now_usage; measure_usage(now_usage); return elapsed_sec(now_usage.ru_stime, then_usage.ru_stime); #else return 0; // TODO: implement Win32 version #endif }
void routesplinesterm() { if (--routeinit > 0) return; free(ps); #ifdef UNUSED free(bs), bs = NULL /*, maxbn = bn = 0 */ ; #endif if (Verbose) fprintf(stderr, "routesplines: %d edges, %d boxes %.2f sec\n", nedges, nboxes, elapsed_sec()); }
double X(measure_execution_time)(plan *pln, const problem *p) { seconds begin, now; double t, tmax, tmin; int iter; int repeat; AWAKE(pln, 1); p->adt->zero(p); start_over: for (iter = 1; iter; iter *= 2) { tmin = 1.0E10; tmax = -1.0E10; begin = getseconds(); /* repeat the measurement TIME_REPEAT times */ for (repeat = 0; repeat < TIME_REPEAT; ++repeat) { t = measure(pln, p, iter); if (t < 0) goto start_over; if (t < tmin) tmin = t; if (t > tmax) tmax = t; /* do not run for too long */ now = getseconds(); t = elapsed_sec(now, begin); if (t > FFTW_TIME_LIMIT) break; } if (tmin >= TIME_MIN) { tmin /= (double) iter; tmax /= (double) iter; AWAKE(pln, 0); return tmin; } } goto start_over; /* may happen if timer is screwed up */ }
ZCE_Auto_Progress_Timer::~ZCE_Auto_Progress_Timer() { end(); std::cout << "This operation use time " << std::setprecision(6) << elapsed_sec() << " second." << std::endl; }
static double elapsed_since(crude_time t0) { return elapsed_sec(clock(), t0); }
static double elapsed_since(crude_time t0) { crude_time t1; gettimeofday(&t1, 0); return elapsed_sec(t1, t0); }
int stress_majorization_cola( vtx_data * graph, /* Input graph in sparse representation */ int n, /* Number of nodes */ int nedges_graph, /* Number of edges */ double **d_coords, /* Coordinates of nodes (output layout) */ node_t **nodes, /* Original nodes */ int dim, /* Dimemsionality of layout */ int model, /* difference model */ int maxi, /* max iterations */ ipsep_options * opt) { int iterations = 0; /* Output: number of iteration of the process */ /************************************************* ** Computation of full, dense, unrestricted k-D ** ** stress minimization by majorization ** ** This function imposes HIERARCHY CONSTRAINTS ** *************************************************/ int i, j, k; float *lap1 = NULL; float *dist_accumulator = NULL; float *tmp_coords = NULL; float **b = NULL; double *degrees = NULL; float *lap2 = NULL; int lap_length; float *f_storage = NULL; float **coords = NULL; int orig_n = n; /*double conj_tol=tolerance_cg; *//* tolerance of Conjugate Gradient */ CMajEnvVPSC *cMajEnvHor = NULL; CMajEnvVPSC *cMajEnvVrt = NULL; double y_0; int length; DistType diameter; float *Dij = NULL; float constant_term; int count; double degree; int step; float val; double old_stress, new_stress = 0; boolean converged; int len; double nsizeScale = 0; float maxEdgeLen = 0; double max = 1; initLayout(graph, n, dim, d_coords, nodes); if (n == 1) return 0; for (i = 0; i < n; i++) { for (j = 1; j < graph[i].nedges; j++) { maxEdgeLen = MAX(graph[i].ewgts[j], maxEdgeLen); } } /**************************************************** ** Compute the all-pairs-shortest-distances matrix ** ****************************************************/ if (maxi == 0) return iterations; if (Verbose) start_timer(); if (model == MODEL_SUBSET) { /* weight graph to separate high-degree nodes */ /* and perform slower Dijkstra-based computation */ if (Verbose) fprintf(stderr, "Calculating subset model"); Dij = compute_apsp_artifical_weights_packed(graph, n); } else if (model == MODEL_CIRCUIT) { Dij = circuitModel(graph, n); if (!Dij) { agerr(AGWARN, "graph is disconnected. Hence, the circuit model\n"); agerr(AGPREV, "is undefined. Reverting to the shortest path model.\n"); } } else if (model == MODEL_MDS) { if (Verbose) fprintf(stderr, "Calculating MDS model"); Dij = mdsModel(graph, n); } if (!Dij) { if (Verbose) fprintf(stderr, "Calculating shortest paths"); Dij = compute_apsp_packed(graph, n); } if (Verbose) { fprintf(stderr, ": %.2f sec\n", elapsed_sec()); fprintf(stderr, "Setting initial positions"); start_timer(); } diameter = -1; length = n + n * (n - 1) / 2; for (i = 0; i < length; i++) { if (Dij[i] > diameter) { diameter = (int) Dij[i]; } } /* for numerical stability, scale down layout */ /* No Jiggling, might conflict with constraints */ for (i = 0; i < dim; i++) { for (j = 0; j < n; j++) { if (fabs(d_coords[i][j]) > max) { max = fabs(d_coords[i][j]); } } } for (i = 0; i < dim; i++) { for (j = 0; j < n; j++) { d_coords[i][j] *= 10 / max; } } /************************** ** Layout initialization ** **************************/ for (i = 0; i < dim; i++) { orthog1(n, d_coords[i]); } /* for the y-coords, don't center them, but translate them so y[0]=0 */ y_0 = d_coords[1][0]; for (i = 0; i < n; i++) { d_coords[1][i] -= y_0; } if (Verbose) fprintf(stderr, ": %.2f sec", elapsed_sec()); /************************** ** Laplacian computation ** **************************/ lap2 = Dij; lap_length = n + n * (n - 1) / 2; square_vec(lap_length, lap2); /* compute off-diagonal entries */ invert_vec(lap_length, lap2); if (opt->clusters->nclusters > 0) { int nn = n + opt->clusters->nclusters * 2; int clap_length = nn + nn * (nn - 1) / 2; float *clap = N_GNEW(clap_length, float); int c0, c1; float v; c0 = c1 = 0; for (i = 0; i < nn; i++) { for (j = 0; j < nn - i; j++) { if (i < n && j < n - i) { v = lap2[c0++]; } else { /* v=j==1?i%2:0; */ if (j == 1 && i % 2 == 1) { v = maxEdgeLen; v *= v; if (v > 0.01) { v = 1.0 / v; } } else v = 0; } clap[c1++] = v; } } free(lap2); lap2 = clap; n = nn; lap_length = clap_length; }