r3996 - in trunk/birnet: . tests



Author: timj
Date: 2006-10-21 11:17:45 -0400 (Sat, 21 Oct 2006)
New Revision: 3996

Modified:
   trunk/birnet/ChangeLog
   trunk/birnet/birnettests.h
   trunk/birnet/birnetutils.cc
   trunk/birnet/birnetutils.hh
   trunk/birnet/tests/sorting.cc
   trunk/birnet/tests/strings.cc
   trunk/birnet/tests/threads.cc
Log:
Sat Oct 21 17:14:54 2006  Tim Janik  <timj gtk org>

        * birnetutils.hh, birnetutils.cc: provide init_settings() function to 
        access initialization setting values. test should now use:
        init_settings().test_perf
        init_settings().test_slow or
        init_settings().test_quick.

        * birnettests.h: fixed float printing.




Modified: trunk/birnet/ChangeLog
===================================================================
--- trunk/birnet/ChangeLog	2006-10-21 02:04:04 UTC (rev 3995)
+++ trunk/birnet/ChangeLog	2006-10-21 15:17:45 UTC (rev 3996)
@@ -1,3 +1,13 @@
+Sat Oct 21 17:14:54 2006  Tim Janik  <timj gtk org>
+
+	* birnetutils.hh, birnetutils.cc: provide init_settings() function to 
+	access initialization setting values. test should now use:
+	init_settings().test_perf
+	init_settings().test_slow or
+	init_settings().test_quick.
+
+	* birnettests.h: fixed float printing.
+
 Sat Oct 21 03:46:05 2006  Tim Janik  <timj gtk org>
 
 	* birnettests.h: added treport_maximized() and treport_minimized()

Modified: trunk/birnet/birnettests.h
===================================================================
--- trunk/birnet/birnettests.h	2006-10-21 02:04:04 UTC (rev 3995)
+++ trunk/birnet/birnettests.h	2006-10-21 15:17:45 UTC (rev 3996)
@@ -26,6 +26,7 @@
 /* this file may be included by C programs */
 
 #include <glib.h>
+#include <string.h>
 
 BIRNET_EXTERN_C_BEGIN();
 
@@ -134,17 +135,17 @@
 		 TUnitType   amount_unit,
 		 int         bias)
 {
-  char buffer[64];
-  snprintf (buffer, sizeof (buffer), "%+.14g", amount);
-  int l = strlen (buffer);
-  char *c = strchr (buffer, '.');
-  int n = c ? c - buffer : l;
+  char numbuf[G_ASCII_DTOSTR_BUF_SIZE + 1] = "";
+  g_ascii_formatd (numbuf, G_ASCII_DTOSTR_BUF_SIZE, "%+.14g", amount);
+  int l = strlen (numbuf);
+  char *c = strchr (numbuf, '.');
+  int n = c ? c - numbuf : l;
   const char spaces[] = "                                             ";
   uint indent = 8 - MIN (8, n);
   g_print ("#TBENCH%s: %25s:%s%s%s %s%c%s\n",
 	   bias > 0 ? "=maxi" : bias < 0 ? "=mini" : "=====",
 	   perf_name,
-	   &spaces[sizeof (spaces) - 1 - indent], buffer, &spaces[sizeof (spaces) - 1 - (23 - MIN (23, indent + l))],
+	   &spaces[sizeof (spaces) - 1 - indent], numbuf, &spaces[sizeof (spaces) - 1 - (23 - MIN (23, indent + l))],
 	   treport_unit (amount_unit & 0xffff),
 	   amount_unit > 0xffff ? '/' : ' ',
 	   treport_unit (amount_unit >> 16));
@@ -247,7 +248,7 @@
   birnet_init (argc, argv, NULL, ivalues);
   unsigned int flags = g_log_set_always_fatal ((GLogLevelFlags) G_LOG_FATAL_MASK);
   g_log_set_always_fatal ((GLogLevelFlags) (flags | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL));
-  if (birnet_init_settings->test_perf)
+  if (init_settings().test_perf)
     g_printerr ("PERF: %s\n", g_get_prgname());
   else
     g_printerr ("TEST: %s\n", g_get_prgname());

Modified: trunk/birnet/birnetutils.cc
===================================================================
--- trunk/birnet/birnetutils.cc	2006-10-21 02:04:04 UTC (rev 3995)
+++ trunk/birnet/birnetutils.cc	2006-10-21 15:17:45 UTC (rev 3996)
@@ -38,6 +38,14 @@
 
 namespace Birnet {
 
+static const InitSettings *birnet_init_settings = NULL;
+
+InitSettings
+init_settings ()
+{
+  return *birnet_init_settings;
+}
+
 /* --- InitHooks --- */
 static void    (*run_init_hooks) () = NULL;
 static InitHook *init_hooks = NULL;
@@ -73,7 +81,6 @@
 }
 
 /* --- initialization --- */
-const InitSettings *birnet_init_settings = NULL;
 static InitSettings global_init_settings = {
   false,        /* stand_alone */
   false,        /* perf_test */

Modified: trunk/birnet/birnetutils.hh
===================================================================
--- trunk/birnet/birnetutils.hh	2006-10-21 02:04:04 UTC (rev 3995)
+++ trunk/birnet/birnetutils.hh	2006-10-21 15:17:45 UTC (rev 3996)
@@ -79,14 +79,14 @@
 /* --- initialization --- */
 typedef BirnetInitValue    InitValue;
 typedef BirnetInitSettings InitSettings;
-extern const InitSettings *birnet_init_settings;
-void   birnet_init       (int        *argcp,
-                          char     ***argvp,
-                          const char *app_name,
-                          InitValue   ivalues[] = NULL);
-bool   init_value_bool   (InitValue  *value);
-double init_value_double (InitValue  *value);
-int64  init_value_int    (InitValue  *value);
+InitSettings init_settings     ();
+void         birnet_init       (int        *argcp,
+                                char     ***argvp,
+                                const char *app_name,
+                                InitValue   ivalues[] = NULL);
+bool         init_value_bool   (InitValue  *value);
+double       init_value_double (InitValue  *value);
+int64        init_value_int    (InitValue  *value);
 
 /* --- initialization hooks --- */
 class InitHook {

Modified: trunk/birnet/tests/sorting.cc
===================================================================
--- trunk/birnet/tests/sorting.cc	2006-10-21 02:04:04 UTC (rev 3995)
+++ trunk/birnet/tests/sorting.cc	2006-10-21 15:17:45 UTC (rev 3996)
@@ -44,7 +44,7 @@
   vector<float> fv;
   vector<float>::iterator fit;
   std::pair<vector<float>::iterator,bool> pit;
-  const uint count = birnet_init_settings->test_quick ? 90000 : 1000000;
+  const uint count = init_settings().test_quick ? 90000 : 1000000;
   TSTART ("Corner case lookups");
   fv.resize (count + (rand() % 10000));
   if (fv.size() % 2)

Modified: trunk/birnet/tests/strings.cc
===================================================================
--- trunk/birnet/tests/strings.cc	2006-10-21 02:04:04 UTC (rev 3995)
+++ trunk/birnet/tests/strings.cc	2006-10-21 15:17:45 UTC (rev 3996)
@@ -27,7 +27,7 @@
 random_tf8_and_unichar_test (void)
 {
   TSTART ("utf8<->unichar");
-  const uint count = birnet_init_settings->test_quick ? 30000 : 1000000;
+  const uint count = init_settings().test_quick ? 30000 : 1000000;
   for (uint i = 0; i < count; i++)
     {
       if (i % 20000 == 0)
@@ -117,7 +117,7 @@
 random_unichar_test (void)
 {
   TSTART ("unichar classification");
-  const uint count = birnet_init_settings->test_quick ? 30000 : 1000000;
+  const uint count = init_settings().test_quick ? 30000 : 1000000;
   for (uint i = 0; i < count; i++)
     {
       unichar uc = rand() % (0x100 << (i % 24));

Modified: trunk/birnet/tests/threads.cc
===================================================================
--- trunk/birnet/tests/threads.cc	2006-10-21 02:04:04 UTC (rev 3995)
+++ trunk/birnet/tests/threads.cc	2006-10-21 15:17:45 UTC (rev 3996)
@@ -883,7 +883,7 @@
 
   birnet_init_test (&argc, &argv);
 
-  if (birnet_init_settings->test_quick)
+  if (init_settings().test_quick)
     {
       test_threads();
       test_atomic();
@@ -891,7 +891,7 @@
       test_thread_atomic_cxx();
       test_auto_locker_cxx();
     }
-  if (birnet_init_settings->test_perf)
+  if (init_settings().test_perf)
     bench_auto_locker_cxx();
   
   return 0;




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]