Run generator with different optimize levels.
@@ -18,6 +18,7 @@ int main (void) {
double start_time = real_usec_time ();
char *start_heap = sbrk (0);
double start_execution_time;
+ MIR_context_t ctx;
MIR_module_t m;
MIR_item_t *funcs;
#if defined(TEST_GEN_LOOP)
@@ -27,8 +28,12 @@ int main (void) {
uint64_t (*fun) (void);
uint64_t res;
#endif
- MIR_context_t ctx = MIR_init ();
-
+ for (unsigned level = 0; level <= 3; level++) {
+ fprintf (stderr, "+++++++++++++Optimize level = %u:\n", level);
+ start_heap = sbrk (0);
+ start_time = real_usec_time ();
+ ctx = MIR_init ();
+ start_time = real_usec_time ();
fprintf (stderr, "MIR_init end -- %.0f usec\n", real_usec_time () - start_time);
funcs = malloc (sizeof (MIR_item_t) * N);
for (int i = 0; i < N; i++) {
@@ -48,6 +53,7 @@ int main (void) {
for (int i = 0; i < N; i++) MIR_load_module (ctx, funcs[i]->module);
MIR_gen_init (ctx);
fprintf (stderr, "MIR_init_gen end -- %.0f usec\n", real_usec_time () - start_time);
+ MIR_gen_set_optimize_level (ctx, level);
#if TEST_GEN_DEBUG
MIR_gen_set_debug_file (ctx, stderr);
#endif
@@ -65,12 +71,16 @@ int main (void) {
res = fun ();
fprintf (stderr, "sieve () -> %ld", (long) res);
#endif
- fprintf (stderr, " -- call %.0f usec, memory used = %.1f KB\n",
- real_usec_time () - start_execution_time, ((char *) sbrk (0) - start_heap) / 1000.0);
+ fprintf (stderr, " -- call %.0f usec", real_usec_time () - start_execution_time);
+ if (level == 0) /* we can accurately messure memory only for the 1st run */
+ fprintf (stderr, ", memory used = %.1f KB\n", ((char *) sbrk (0) - start_heap) / 1000.0);
+ else
+ fprintf (stderr, "\n");
MIR_gen_finish (ctx);
fprintf (stderr, "MIR_finish_gen end -- %.0f usec\n", real_usec_time () - start_time);
MIR_finish (ctx);
fprintf (stderr, "MIR_finish end -- %.0f usec\n", real_usec_time () - start_time);
free (funcs);
+ }
return 0;
}
