Revision: 1353
Author: [email protected]
Date: Tue Sep 14 14:17:41 2010
Log: Add Devel::NYTProf::Test::ticks_for_usleep($usec) to help test clocks
http://code.google.com/p/perl-devel-nytprof/source/detail?r=1353

Modified:
 /trunk/NYTProf.xs

=======================================
--- /trunk/NYTProf.xs   Sun Sep 12 05:01:13 2010
+++ /trunk/NYTProf.xs   Tue Sep 14 14:17:41 2010
@@ -1386,6 +1386,7 @@

     reinit_if_forked(aTHX);

+    /* XXX move down into the (file != last_executed_fileptr) block ? */
     CHECK_SAWAMPERSAND(last_executed_fid, last_executed_line);

     if (last_executed_fid) {
@@ -4933,6 +4934,31 @@
     CODE:
     SETERRNO(e, 0);

+void
+ticks_for_usleep(long u_seconds)
+    PPCODE:
+    long elapsed = -1, overflow = -1;
+#ifdef HAS_SELECT
+    time_of_day_t s_time;
+    time_of_day_t e_time;
+    struct timeval timebuf;
+
+    timebuf.tv_sec  = (long)(u_seconds / 1000000);
+    timebuf.tv_usec = u_seconds - (timebuf.tv_sec * 1000000);
+
+    get_time_of_day(s_time);
+    PerlSock_select(0, 0, 0, 0, &timebuf);
+    get_time_of_day(e_time);
+    get_ticks_between(s_time, e_time, elapsed, overflow);
+#else
+    PERL_UNUSED_VAR(u_seconds);
+#endif
+    EXTEND(SP, 4);
+    PUSHs(sv_2mortal(newSVnv(elapsed)));
+    PUSHs(sv_2mortal(newSVnv(overflow)));
+    PUSHs(sv_2mortal(newSVnv(CLOCKS_PER_TICK)));
+    PUSHs(sv_2mortal(newSViv(profile_clock)));
+

 MODULE = Devel::NYTProf     PACKAGE = DB

--
You've received this message because you are subscribed to
the Devel::NYTProf Development User group.

Group hosted at:  http://groups.google.com/group/develnytprof-dev
Project hosted at:  http://perl-devel-nytprof.googlecode.com
CPAN distribution:  http://search.cpan.org/dist/Devel-NYTProf

To post, email:  [email protected]
To unsubscribe, email:  [email protected]

Reply via email to