Author: tim.bunce
Date: Thu Nov 13 05:17:55 2008
New Revision: 601

Modified:
    trunk/bin/nytprofcsv

Log:
Some initial exploratory work towards extending nytprofcsv to include
higher-level detail, like nytprofhtml does, and so be useful for testing  
same.
Needs more data model work, though, to avoid duplicating too much  
nytprofhtml logic.


Modified: trunk/bin/nytprofcsv
==============================================================================
--- trunk/bin/nytprofcsv        (original)
+++ trunk/bin/nytprofcsv        Thu Nov 13 05:17:55 2008
@@ -22,17 +22,25 @@

  use constant NUMERIC_PRECISION => 5;

+my %delimiters = (
+    comma => ",",
+    tab   => "\t",
+);
+
  my %opt = (
      file => 'nytprof.out',
      out  => 'nytprof',
+    delim => 'comma',
  );
-GetOptions(\%opt, qw/file|f=s delete|d out|o=s help|h/) or exit 1;
+GetOptions(\%opt, qw/file|f=s delete|d out|o=s help|h delim=s annotated| 
a/) or exit 1;

  if (defined($opt{help})) {
      &usage;
      exit 1;
  }

+$opt{delim} = $delimiters{ $opt{delim} } if exists $delimiters{  
$opt{delim} };
+
  # handle file selection option
  if (!-r $opt{file}) {
      die "$0: Unable to access $opt{file}\n";
@@ -64,12 +72,26 @@
  $reporter->set_param(mk_report_source_line => sub {
      my ($linenum, $line, $stats_for_line, $statistics, $subs_defined,  
$makes_calls_to, $profile, $filestr) = @_;
      $line =~ s/^\s*//; # trim leading spaces
-    return sprintf("%f,%g,%f,%s\n",
-        $stats_for_line->{'time'} || 0,
-        $stats_for_line->{'calls'} || 0,
-        $stats_for_line->{'time/call'} || 0,
+    my $delim = $opt{delim};
+    my $text = sprintf("%f%s%g%s%f%s%s\n",
+        $stats_for_line->{'time'}      || 0, $delim,
+        $stats_for_line->{'calls'}     || 0, $delim,
+        $stats_for_line->{'time/call'} || 0, $delim,
          $line,
      );
+    return $text unless $opt{annotated};
+
+    # srcline
+    $text = "srcline$delim$text";
+
+    if (@$subs_defined) {
+        # subdefn
+        # callers
+    }
+    if (@$makes_calls_to) {
+        # calling
+    }
+    return $text;
  });

  $reporter->set_param(mk_report_xsub_line => sub { "" });

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