Revision: 1355
Author: [email protected]
Date: Wed Sep 15 02:12:22 2010
Log: Preliminary reworking of statement time i/o

NYTP_write_time_* now take I32 elapsed instead of unsigned int elapsed.
If elapsed is < 0 issue a warning and treat as zero.
NYTP_write_time_* now take an extra U32 overflow arg.
If overflow is > 0 issue a warning.

nytprofmerge adjusted to account for overflow (though always 0 for now).

nytprofmerge no longer add " (N runs)" to application name unless N > 1
so "NYTPROF_TEST_MERGERDT=1 make test" works (though one test fails, which
is probably an nytprofmerge bug but I've no time to look deeper).

http://code.google.com/p/perl-devel-nytprof/source/detail?r=1355

Modified:
 /trunk/FileHandle.h
 /trunk/FileHandle.xs
 /trunk/NYTProf.xs
 /trunk/bin/nytprofmerge

=======================================
--- /trunk/FileHandle.h Wed Jul  7 10:05:28 2010
+++ /trunk/FileHandle.h Wed Sep 15 02:12:22 2010
@@ -101,12 +101,10 @@
unsigned int eval_fid, unsigned int eval_line_num,
                           unsigned int flags, unsigned int size,
                           unsigned int mtime, const char *name, I32 len);
-size_t NYTP_write_time_block(NYTP_file ofile, unsigned int elapsed,
-                             unsigned int fid, unsigned int line,
-                             unsigned int last_block_line,
-                             unsigned int last_sub_line);
-size_t NYTP_write_time_line(NYTP_file ofile, unsigned int elapsed,
-                            unsigned int fid, unsigned int line);
+size_t NYTP_write_time_block(NYTP_file ofile, I32 elapsed, U32 overflow,
+ U32 fid, U32 line, U32 last_block_line, U32 last_sub_line);
+size_t NYTP_write_time_line(NYTP_file ofile, I32 elapsed, U32 overflow,
+                        U32 fid, U32 line);
 size_t NYTP_write_sub_info(NYTP_file ofile, unsigned int fid,
                            const char *name, I32 len,
unsigned int first_line, unsigned int last_line);
=======================================
--- /trunk/FileHandle.xs        Thu Jul 15 08:30:03 2010
+++ /trunk/FileHandle.xs        Wed Sep 15 02:12:22 2010
@@ -945,11 +945,20 @@
 }

 static size_t
-write_time_common(NYTP_file ofile, unsigned char tag, unsigned int elapsed,
-                  unsigned int fid, unsigned int line)
+write_time_common(NYTP_file ofile, unsigned char tag, I32 elapsed, U32 overflow,
+                  U32 fid, U32 line)
 {
     size_t total;
     size_t retval;
+
+ if (overflow) /* XXX temp - needs protocol change to add new tag */ + fprintf(stderr, "profile time overflow of %lu seconds discarded!\n",
+            (unsigned long)overflow);
+
+    if (elapsed < 0) {  /* XXX temp - needs support for signed ints */
+        fprintf(stderr, "Negative time %ld recorded as 0\n", elapsed);
+        elapsed = 0;
+    }

     total = retval = output_tag_int(ofile, tag, elapsed);
     if (retval < 1)
@@ -967,14 +976,13 @@
 }

 size_t
-NYTP_write_time_block(NYTP_file ofile, unsigned int elapsed, unsigned int fid,
-                      unsigned int line, unsigned int last_block_line,
-                      unsigned int last_sub_line)
+NYTP_write_time_block(NYTP_file ofile, I32 elapsed, U32 overflow,
+    U32 fid, U32 line, U32 last_block_line, U32 last_sub_line)
 {
     size_t total;
     size_t retval;

-    total = retval = write_time_common(ofile, NYTP_TAG_TIME_BLOCK, elapsed,
+ total = retval = write_time_common(ofile, NYTP_TAG_TIME_BLOCK, elapsed, overflow,
                                        fid, line);
     if (retval < 1)
         return retval;
@@ -991,10 +999,10 @@
 }

 size_t
-NYTP_write_time_line(NYTP_file ofile, unsigned int elapsed, unsigned int fid,
-                     unsigned int line)
-{
- return write_time_common(ofile, NYTP_TAG_TIME_LINE, elapsed, fid, line);
+NYTP_write_time_line(NYTP_file ofile, I32 elapsed, U32 overflow,
+    U32 fid, U32 line)
+{
+ return write_time_common(ofile, NYTP_TAG_TIME_LINE, elapsed, overflow, fid, line);
 }

 size_t
@@ -1228,18 +1236,20 @@
         RETVAL

 size_t
-NYTP_write_time_block(handle, elapsed, fid, line, last_block_line, last_sub_line) +NYTP_write_time_block(handle, elapsed, overflow, fid, line, last_block_line, last_sub_line)
 NYTP_file handle
-unsigned int elapsed
+U32 elapsed
+unsigned int overflow
 unsigned int fid
 unsigned int line
 unsigned int last_block_line
 unsigned int last_sub_line

 size_t
-NYTP_write_time_line(handle, elapsed, fid, line)
+NYTP_write_time_line(handle, elapsed, overflow, fid, line)
 NYTP_file handle
-unsigned int elapsed
+U32 elapsed
+unsigned int overflow
 unsigned int fid
 unsigned int line

@@ -1310,3 +1320,4 @@
 NYTP_file handle
 unsigned int major
 unsigned int minor
+
=======================================
--- /trunk/NYTProf.xs   Tue Sep 14 14:46:12 2010
+++ /trunk/NYTProf.xs   Wed Sep 15 02:12:22 2010
@@ -1381,8 +1381,6 @@
         get_time_of_day(end_time);
         get_ticks_between(start_time, end_time, elapsed, overflow);
     }
- if (overflow) /* XXX later output overflow to file */ - logwarn("profile time overflow of %ld seconds discarded!\n", overflow);

     reinit_if_forked(aTHX);

@@ -1391,11 +1389,11 @@

     if (last_executed_fid) {
         if (profile_blocks)
-            NYTP_write_time_block(out, elapsed, last_executed_fid,
+ NYTP_write_time_block(out, elapsed, overflow, last_executed_fid,
                                   last_executed_line, last_block_line,
                                   last_sub_line);
         else
-            NYTP_write_time_line(out, elapsed, last_executed_fid,
+            NYTP_write_time_line(out, elapsed, overflow, last_executed_fid,
                                  last_executed_line);

         if (trace_level >= 5)
=======================================
--- /trunk/bin/nytprofmerge     Sun Sep 12 05:01:13 2010
+++ /trunk/bin/nytprofmerge     Wed Sep 15 02:12:22 2010
@@ -59,9 +59,8 @@
 my @pending_fids;
 my %pending_subs;

-sub _time_block_or_line {
+sub _write_time_block_or_line {
     my ($tag, $ticks, $fid, $line, $block_line, $sub_line) = @_;
-    my $is_line = $tag eq 'TIME_LINE';

     confess("No mapping for $fid") unless defined $fids{$fid};
     $fid = $fids{$fid};
@@ -69,10 +68,11 @@
     my $mapped_fid = $map_range{$fid}[$line];
     $fid = $mapped_fid if defined $mapped_fid;

-    if ($is_line) {
-       $out->write_time_line($ticks, $fid, $line);
+    # XXX overflow isn't passed in or through
+    if ($tag eq 'TIME_LINE') {
+       $out->write_time_line($ticks, 0, $fid, $line);
     } else {
-       $out->write_time_block($ticks, $fid, $line, $block_line, $sub_line);
+       $out->write_time_block($ticks, 0, $fid, $line, $block_line, $sub_line);
     }
 }

@@ -152,8 +152,8 @@
         $out->write_new_fid($new_fid, $new_eval_fid, $eval_line, $flags,
                             $size, $mtime, $name);
      },
-     TIME_BLOCK => \&_time_block_or_line,
-     TIME_LINE => \&_time_block_or_line,
+     TIME_BLOCK => \&_write_time_block_or_line,
+     TIME_LINE  => \&_write_time_block_or_line,

      DISCOUNT => sub {
         $out->write_discount();
@@ -316,8 +316,8 @@
        my @grouped;
        foreach my $prog (sort keys %counts) {
            my $count = $counts{$prog};
-           push @grouped,
-               sprintf "$prog ($count run%s)", $count == 1 ? '' : 's';
+           push @grouped, $prog;
+            $grouped[-1] .= " ($count runs)" if $count > 1;
        }
        my $last = pop @grouped;
        my $value = @grouped ? join (', ', @grouped) . " and $last" : $last;

--
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