[svn:parrot] r45214 - in branches/profiling_testing: . runtime/parrot/library/ProfTest

cotto at svn.parrot.org cotto at svn.parrot.org
Sat Mar 27 22:59:01 UTC 2010


Author: cotto
Date: Sat Mar 27 22:59:01 2010
New Revision: 45214
URL: https://trac.parrot.org/parrot/changeset/45214

Log:
[profiling] more profiling testing updates, possibly closer to usable

Deleted:
   branches/profiling_testing/runtime/parrot/library/ProfTest/ProfTest.nqp
Modified:
   branches/profiling_testing/MANIFEST
   branches/profiling_testing/runtime/parrot/library/ProfTest/Matcher.nqp
   branches/profiling_testing/runtime/parrot/library/ProfTest/PIRProfile.nqp
   branches/profiling_testing/runtime/parrot/library/ProfTest/Want.nqp

Modified: branches/profiling_testing/MANIFEST
==============================================================================
--- branches/profiling_testing/MANIFEST	Sat Mar 27 22:45:23 2010	(r45213)
+++ branches/profiling_testing/MANIFEST	Sat Mar 27 22:59:01 2010	(r45214)
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Sat Mar 27 04:26:41 2010 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Sat Mar 27 22:33:09 2010 UT
 #
 # See below for documentation on the format of this file.
 #
@@ -1241,7 +1241,6 @@
 runtime/parrot/library/Pg.pir                               [library]
 runtime/parrot/library/ProfTest/Matcher.nqp                 [library]
 runtime/parrot/library/ProfTest/PIRProfile.nqp              [library]
-runtime/parrot/library/ProfTest/ProfTest.nqp                [library]
 runtime/parrot/library/ProfTest/Want.nqp                    [library]
 runtime/parrot/library/Protoobject.pir                      [library]
 runtime/parrot/library/Range.pir                            [library]

Modified: branches/profiling_testing/runtime/parrot/library/ProfTest/Matcher.nqp
==============================================================================
--- branches/profiling_testing/runtime/parrot/library/ProfTest/Matcher.nqp	Sat Mar 27 22:45:23 2010	(r45213)
+++ branches/profiling_testing/runtime/parrot/library/ProfTest/Matcher.nqp	Sat Mar 27 22:59:01 2010	(r45214)
@@ -8,7 +8,7 @@
     );
     self<wants>.unshift(
         ProfTest::Want::Goal.new()
-    };
+    );
     for @args -> $arg {
         self<wants>.push($arg);
     }
@@ -16,16 +16,33 @@
 
 method matches($profile) {
 
-    #if this is the last line
-        #exhaust the current want
+    my @backtracks := ();
+    my $line_idx   := 0;
+    my $want_idx   := 0;
+
+    my $curr_line := $profile.profile_array[$line_idx];
+    my $curr_want := self<wants>[$want_idx];
 
-    #if we're at a goal
-        #return true
-    #elsif this want accepts the current profile line
-        #if this want is unexhausted, push it onto the backtrack stack
-        #move to the next want and profile line
-    #else
-        #backtrack to the previous unexhausted want
+    while (11) {
+        if $curr_want.goal {
+            return 1;
+        }
+        elsif ($curr_want.accepts($curr_line)) {
 
+            @backtracks.push( [$line_idx+1, $want_idx] );
+            $line_idx++;
+            $want_idx++;
+            $curr_line := $profile.profile_array[$line_idx];
+            $curr_want := self<wants>[$want_idx];
+        }
+        else {
+            if !@backtracks {
+                return 0;
+            }
+            ($curr_want, $curr_line) := @backtracks.pop;
+            $curr_line := $profile.profile_array[$line_idx];
+            $curr_want := self<wants>[$want_idx];
+        }
+    }
 }
 

Modified: branches/profiling_testing/runtime/parrot/library/ProfTest/PIRProfile.nqp
==============================================================================
--- branches/profiling_testing/runtime/parrot/library/ProfTest/PIRProfile.nqp	Sat Mar 27 22:45:23 2010	(r45213)
+++ branches/profiling_testing/runtime/parrot/library/ProfTest/PIRProfile.nqp	Sat Mar 27 22:59:01 2010	(r45214)
@@ -9,6 +9,10 @@
     self;
 }
 
+method profile_array() {
+    self<profile_array>;
+}
+
 method build_profile_array() {
 
     my @pprof_lines := pir::split("\n", self<profile>);
@@ -30,8 +34,8 @@
 
     for @pprof_lines -> $line {
         my $line_match := pprof_line.parse($line);
-        pir::say($line);
-        _dumper($line_match);
+        #pir::say($line);
+        #_dumper($line_match);
         self<profile_array>.push($line_match);
     }
 }

Deleted: branches/profiling_testing/runtime/parrot/library/ProfTest/ProfTest.nqp
==============================================================================
--- branches/profiling_testing/runtime/parrot/library/ProfTest/ProfTest.nqp	Sat Mar 27 22:59:01 2010	(r45213)
+++ /dev/null	00:00:00 1970	(deleted)
@@ -1,77 +0,0 @@
-#!/usr/bin/env parrot-nqp
-
-INIT {
-    # Load the Test::More library
-    pir::load_language('parrot');
-    pir::compreg__PS('parrot').import('Test::More');
-
-    pir::load_bytecode('dumper.pbc');
-}
-
-
-sub get_profile_array($pprof) {
-
-    my @pprof_lines := pir::split("\n", $pprof);
-    my @pprof := ();
-
-    grammar pprof_line {
-        rule TOP { ^^ [ <fixed_line> | <variable_line> ] $$ }
-        
-        rule fixed_line      { <fixed_line_type> ':' <fixed_line_data> }
-        rule fixed_line_type { [ 'VERSION' | 'CLI' | 'END_OF_RUNLOOP' ] }
-        rule fixed_line_data { \N* }
-
-        rule variable_line      { <variable_line_type> ':' <variable_line_data>* }
-        rule variable_line_type { [ 'CS' | 'OP' ] }
-        rule variable_line_data { '{x{' <field_name> ':' <field_data> '}x}' }
-        rule field_name         { <.ident> }
-        rule field_data         { <[a..zA..Z0..9_\-]>* }
-    }
-
-    for @pprof_lines -> $line {
-        my $line_match := pprof_line.parse($line);
-        #pir::say($line);
-        _dumper($line_match);
-        @pprof.push($line_match);
-    }
-    @pprof;
-}
-
-sub get_profile_from_pir($pir, $canonical? = 1) {
-
-    my $tmp_pir := '/tmp/test.pir';
-    my $tmp_pprof := '/tmp/test.pprof';
-    my $fh := pir::new__p_sc('FileHandle');
-    $fh.open($tmp_pir, "w");
-    $fh.puts($pir);
-    $fh.close();
-
-    my %env := pir::new__p_sc('Env');
-    %env{'PARROT_PROFILING_FILENAME'} := $tmp_pprof;
-    if $canonical {
-        %env{'PARROT_PROFILING_CANONICAL_OUTPUT'} := 1;
-    }
-    
-    my %config := get_config();
-    my $parrot_exe := %config<prefix> ~ %config<slash> ~ %config<test_prog>;
-
-    my $cli := "$parrot_exe --hash-seed=1234 --runcore profiling $tmp_pir";  
-
-    my $pipe := pir::new__p_sc('FileHandle');
-    $pipe.open($cli, "rp");
-    $pipe.readall();
-    my $exit_status := $pipe.exit_status();
-
-    my $pprof_fh := pir::new__p_sc('FileHandle');
-    $pprof_fh.readall($tmp_pprof);
-}
-
-sub get_config() {
-    return Q:PIR {
-        .include 'iglobals.pasm'
-        .local pmc i
-        i = getinterp
-        %r = i[.IGLOBALS_CONFIG_HASH]
-    };
-}
-        

Modified: branches/profiling_testing/runtime/parrot/library/ProfTest/Want.nqp
==============================================================================
--- branches/profiling_testing/runtime/parrot/library/ProfTest/Want.nqp	Sat Mar 27 22:45:23 2010	(r45213)
+++ branches/profiling_testing/runtime/parrot/library/ProfTest/Want.nqp	Sat Mar 27 22:59:01 2010	(r45214)
@@ -13,16 +13,20 @@
     %h;
 }
 
-method exhaust() {
-    self<exhausted> := 1;
+method exhaust($x? = 1) {
+    self<exhausted> := $x;
 }
 
+method exhausted() { self<exhausted>; }
+
+method goal() { 0; }
+
 
 class ProfTest::Want::Goal;
 
 method new() { }
 
-method accepts($prof_line) { 1; }
+method goal() { 1; }
 
 
 
@@ -44,7 +48,6 @@
             return 0;
         }
     }
-    #XXX: how does this get exhausted?
     return 1;
 }
 
@@ -133,7 +136,6 @@
 
 method accepts($prof_line) {
     if self<found_cs> && self<slurp_until> {
-        #XXX: how to properly exhaust this?
         return $prof_line<variable_line><line_type> ne self<slurp_until>;
     }
     elsif $prof_line<variable_line> && $prof_line<variable_line><line_type> eq 'CS' {


More information about the parrot-commits mailing list