greghendershott / markdown

Markdown parser written in Racket.
100 stars 28 forks source link

add <or> profiling option #44

Closed stchang closed 10 years ago

stchang commented 10 years ago

Here's my quick and dirty <or> profiler.

Here's a sample output with OR-DEBUG = #t:

~/racket/markdown-stchang/markdown$ racket
Welcome to Racket v6.0.1.13.
-> (require "parse.rkt")
-> (let ([s (file->string "test/test.md")])
     (let ([doc (string-join (for/list ([i 5]) s) "\n\n")])
       (time (void (parse-markdown doc)))))
40: (enclosed (string **) (try (string **)) $inline)
15: (enclosed (string __) (try (string __)) $inline)

60: (emph _)
10: (emph *)

40: $link/reference
16: $link/explicit

30: $bullet-list
20: $ordered-list

231: (many1 $blank-line)
0: (lookAhead $html/block)

145: $bullet-list-start
100: $ordered-list-start

820: $anyChar
0: $html-comment

157: (many1 (noneOf (rkt:string open close)))
0: (pdo (xs <- (inner open close)) (return (append (list open) xs (list close))))

21: (try (>>= (chars-in-balanced ( )) (curry parse-from-string $_source+title)))
0: (pdo (>>= (pdo (xs <- (enclosed (char () (char )) $anyChar)) (return (list->string xs))) (curry parse-from-string $_source+title)))

21: (source-url     
)
0: (try (pdo (char <) (xs <- (source-url >  
)) (char >) (return xs)))

563: (noneOf (string-append   excludes))

10: $space-char
0: $newline

231: $para
85: $plain
50: $list
20: $heading
20: $hr
15: (unless-strict $footnote-def)
15: (unless-strict $verbatim/fenced)
11: $blockquote
10: $html/block
10: $reference
6: $verbatim/indent
5: (unless-strict $image/block)

21: (try $indented-line)
0: (try (pdo (bs <- (many (pdo $blank-line (return )))) (i <- $indented-line) (return (string-join (quasiquote ((unquote-splicing bs) (unquote i))) 
))))

166: (string     )
0: (string  )

5: (image/explicit #t)
0: (image/reference #t)

50: $inline
0: $trailing-hashes-before-newline

3466: $str
2702: $whitespace
421: $special
146: $end-line
95: (unless-strict $smart-punctuation)
90: $code
70: $emph
56: (parse-unless ignore-inline-links? $link)
45: $strong
25: (unless-strict $footnote-ref)
20: (parse-unless ignore-inline-links? $autolink)
10: $html/inline
6: $entity
0: $image/inline
0: (<or> (4+ *) (4+ _))

...
greghendershott commented 10 years ago

Thanks! For now, I pulled your branch and merged to my master, just locally. But I expect to push it. Just want to experiment with using it for awhile, first.

stchang commented 10 years ago

Ah yeah, the pull request was just meant to show you. I didnt intend to merge it to master.