diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-02-26 16:26:55 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-02-26 16:26:55 -0800 |
commit | d396748e6c57fa4af9f553bdf1ee1c8d14f83cbf (patch) | |
tree | 1126780ce4abdbd6499e103fa8b3d1706c2e318e | |
parent | 5210a9d14ff34c335bbd423e5367b926f8092dee (diff) | |
download | mu-d396748e6c57fa4af9f553bdf1ee1c8d14f83cbf.tar.gz |
839 - profiling parse-trace
Ok, it's not super-linear, at least on the level of mu. Parsing is just inefficient. To profile stages inside main: grep "^run: " .traces/p? |column 2 |perl -pwe 's,.*/([^/]*)/([^/]*) ,$1/$2 ,' |sort |freq |sort -nrk2
-rw-r--r-- | profile-parse-trace.arc | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/profile-parse-trace.arc b/profile-parse-trace.arc new file mode 100644 index 00000000..37c85e16 --- /dev/null +++ b/profile-parse-trace.arc @@ -0,0 +1,93 @@ +(load "mu.arc") +(set allow-raw-addresses*) + +(reset) +(new-trace "p1") +(add-code:readfile "trace.mu") +(add-code + '((function! main [ + (default-space:space-address <- new space:literal 30:literal/capacity) + (x:string-address <- new +"run: main 0: (((1 integer)) <- ((copy)) ((1 literal)))") + (n:integer <- length x:string-address/deref) + ($print (("p1 " literal))) + ($print n:integer) + ($print (("\n" literal))) + (s:stream-address <- init-stream x:string-address) + (traces:instruction-trace-address-array-address <- parse-traces s:stream-address) + ]))) +(run 'main) + +(reset) +(new-trace "p2") +(add-code:readfile "trace.mu") +(add-code + '((function! main [ + (default-space:space-address <- new space:literal 30:literal/capacity) + (x:string-address <- new +"schedule: main +run: main 0: (((1 integer)) <- ((copy)) ((1 literal))) +run: main 0: 1 => ((1 integer)) +mem: ((1 integer)): 1 <= 1") + (n:integer <- length x:string-address/deref) + ($print (("p2 " literal))) + ($print n:integer) + ($print (("\n" literal))) + (s:stream-address <- init-stream x:string-address) + (traces:instruction-trace-address-array-address <- parse-traces s:stream-address) + ]))) +(run 'main) + +(reset) +(new-trace "p3") +(add-code:readfile "trace.mu") +(add-code + '((function! main [ + (default-space:space-address <- new space:literal 30:literal/capacity) + (x:string-address <- new +"schedule: main +run: main 0: (((1 integer)) <- ((copy)) ((1 literal))) +run: main 0: 1 => ((1 integer)) +mem: ((1 integer)): 1 <= 1 +run: main 1: (((2 integer)) <- ((copy)) ((3 literal))) +run: main 1: 3 => ((2 integer)) +mem: ((2 integer)): 2 <= 3") + (n:integer <- length x:string-address/deref) + ($print (("p3 " literal))) + ($print n:integer) + ($print (("\n" literal))) + (s:stream-address <- init-stream x:string-address) + (traces:instruction-trace-address-array-address <- parse-traces s:stream-address) + ]))) +(run 'main) + +(reset) +(new-trace "p4") +(add-code:readfile "trace.mu") +(add-code + '((function! main [ + (default-space:space-address <- new space:literal 30:literal/capacity) + (x:string-address <- new +"schedule: main +run: main 0: (((1 integer)) <- ((copy)) ((1 literal))) +run: main 0: 1 => ((1 integer)) +mem: ((1 integer)): 1 <= 1 +run: main 1: (((2 integer)) <- ((copy)) ((3 literal))) +run: main 1: 3 => ((2 integer)) +mem: ((2 integer)): 2 <= 3 +run: main 2: (((3 integer)) <- ((add)) ((1 integer)) ((2 integer))) +mem: ((1 integer)) => 1 +mem: ((2 integer)) => 3 +run: main 2: 4 => ((3 integer)) +mem: ((3 integer)): 3 <= 4 +schedule: done with routine") + (n:integer <- length x:string-address/deref) + ($print (("p4 " literal))) + ($print n:integer) + ($print (("\n" literal))) + (s:stream-address <- init-stream x:string-address) + (traces:instruction-trace-address-array-address <- parse-traces s:stream-address) + ]))) +(run 'main) + +(reset) |