test: fix profiling code
authorDavid Schleef <ds@schleef.org>
Tue, 6 Oct 2009 01:56:20 +0000 (18:56 -0700)
committerDavid Schleef <ds@schleef.org>
Tue, 6 Oct 2009 01:56:48 +0000 (18:56 -0700)
orc-test/orcprofile.c
orc-test/orcprofile.h
orc-test/orctest.c

index 77ae0e1..7068694 100644 (file)
@@ -148,7 +148,24 @@ orc_profile_get_ave_std (OrcProfile *prof, double *ave_p, double *std_p)
   if (std_p) *std_p = std;
 }
 
-unsigned long (*_orc_profile_stamp)(void);
+
+static unsigned long
+oil_profile_stamp_default (void)
+{
+#if defined(HAVE_CLOCK_GETTIME) && defined(HAVE_MONOTONIC_CLOCK)
+  struct timespec ts;
+  clock_gettime (CLOCK_MONOTONIC, &ts);
+  return 1000000000*ts.tv_sec + ts.tv_nsec;
+#elif defined(HAVE_GETTIMEOFDAY)
+  struct timeval tv;
+  gettimeofday(&tv,NULL);
+  return 1000000*(unsigned long)tv.tv_sec + (unsigned long)tv.tv_usec;
+#else
+  return 0;
+#endif
+}
+
+static unsigned long (*_orc_profile_stamp)(void) = oil_profile_stamp_default;
 
 /**
  * orc_profile_stamp:
@@ -164,3 +181,9 @@ orc_profile_stamp (void)
   return _orc_profile_stamp();
 }
 
+void
+_orc_profile_init (void)
+{
+
+}
+
index 95c996f..277fd59 100644 (file)
@@ -32,8 +32,6 @@
 
 ORC_BEGIN_DECLS
 
-#ifdef ORC_ENABLE_UNSTABLE_API
-
 /**
  * ORC_PROFILE_HIST_LENGTH
  *
@@ -89,10 +87,8 @@ void orc_profile_get_ave_std (OrcProfile *prof, double *ave_p, double *std_p);
         orc_profile_stop_handle(x); \
 }while(0)
 
-#endif
 
 ORC_END_DECLS
 
-
 #endif
 
index 8020858..5ba4c7c 100644 (file)
@@ -13,6 +13,7 @@
 #include <string.h>
 #include <math.h>
 
+void _orc_profile_init(void);
 
 OrcRandomContext rand_context;
 
@@ -24,6 +25,7 @@ orc_test_init (void)
   setvbuf (stdout, NULL, _IONBF, 0);
 
   orc_random_init (&rand_context, 0x12345678);
+  _orc_profile_init ();
 }