diff options
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/benchmark.c | 20 | ||||
| -rw-r--r-- | modules/benchmark/blowfish.c | 8 | 
2 files changed, 19 insertions, 9 deletions
| diff --git a/modules/benchmark.c b/modules/benchmark.c index 9d4e80d7..fffc0864 100644 --- a/modules/benchmark.c +++ b/modules/benchmark.c @@ -67,7 +67,7 @@ struct _ParallelBenchTask {      gpointer	data, callback;  }; -gpointer benchmark_parallel_for_dispatcher(gpointer data) +static gpointer benchmark_parallel_for_dispatcher(gpointer data)  {      ParallelBenchTask 	*pbt = (ParallelBenchTask *)data;      gpointer 		(*callback)(unsigned int start, unsigned int end, void *data, gint thread_number); @@ -133,7 +133,7 @@ gdouble benchmark_parallel_for(guint start, guint end,          thread = g_thread_create((GThreadFunc) benchmark_parallel_for_dispatcher,                                   pbt, TRUE, NULL); -        threads = g_slist_append(threads, thread); +        threads = g_slist_prepend(threads, thread);          DEBUG("thread %d launched as context %p", thread_number, thread);      } @@ -319,6 +319,8 @@ static gboolean do_benchmark_handler(GIOChannel *source,      BenchmarkDialog *bench_dialog = (BenchmarkDialog*)data;      GIOStatus status;      gchar *result; +    gchar *buffer; +    float float_result;      status = g_io_channel_read_line(source, &result, NULL, NULL, NULL);      if (status != G_IO_STATUS_NORMAL) { @@ -329,7 +331,14 @@ static gboolean do_benchmark_handler(GIOChannel *source,          return FALSE;      } -    bench_dialog->result = atof(result); +    float_result = strtof(result, &buffer); +    if (buffer == result) { +        DEBUG("error while converting floating point value"); +        bench_dialog->result = -1.0f; +    } else { +        bench_dialog->result = float_result; +    } +      gtk_widget_destroy(bench_dialog->dialog);      g_free(result); @@ -635,6 +644,11 @@ void hi_module_init(void)      sync_manager_add_entry(&se[0]);      sync_manager_add_entry(&se[1]); + +    int i; +    for (i = 0; i < G_N_ELEMENTS(entries) - 1; i++) { +         bench_results[i] = -1.0f; +    }  }  gchar **hi_module_get_dependencies(void) diff --git a/modules/benchmark/blowfish.c b/modules/benchmark/blowfish.c index b18b3570..feadc430 100644 --- a/modules/benchmark/blowfish.c +++ b/modules/benchmark/blowfish.c @@ -514,13 +514,12 @@ parallel_blowfish(unsigned int start, unsigned int end, void *data, gint thread_  void  benchmark_fish(void)  { -    gdouble elapsed = 0;      gchar *tmpsrc; -      gchar *bdata_path;      bdata_path = g_build_filename(params.path_data, "benchmark.data", NULL);      if (!g_file_get_contents(bdata_path, &tmpsrc, NULL, NULL)) { +        bench_results[BENCHMARK_BLOWFISH] = -1.0f;          g_free(bdata_path);          return;      } @@ -528,10 +527,7 @@ benchmark_fish(void)      shell_view_set_enabled(FALSE);      shell_status_update("Performing Blowfish benchmark..."); -    elapsed = benchmark_parallel_for(0, 50000, parallel_blowfish, tmpsrc); - +    bench_results[BENCHMARK_BLOWFISH] = benchmark_parallel_for(0, 50000, parallel_blowfish, tmpsrc);      g_free(bdata_path);      g_free(tmpsrc); - -    bench_results[BENCHMARK_BLOWFISH] = elapsed;  } | 
