From 651851564a3c24894bc3bb9f1f5d9dd016e553ed Mon Sep 17 00:00:00 2001 From: cho45 Date: Thu, 2 Dec 2010 22:45:33 +0900 Subject: [PATCH] benchmark --- .gitignore | 1 - benchmark/benchmark.pl | 92 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 1 deletion(-) create mode 100755 benchmark/benchmark.pl diff --git a/.gitignore b/.gitignore index 2b07642..f63bea8 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,3 @@ inc Makefile.old MANIFEST.bak nytprof* -benchmark/* diff --git a/benchmark/benchmark.pl b/benchmark/benchmark.pl new file mode 100755 index 0000000..a568962 --- /dev/null +++ b/benchmark/benchmark.pl @@ -0,0 +1,92 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use utf8; +use Benchmark qw(:all) ; + +my $text = <|perl| +test code +||< + +^L + +Markdown +======== + +This is markdown + + * foo + * bar + * baz + + 1. aaa + 2. bbb + 3. ccc + + + test code + +^L + +h1. Textile + +A _simple_ demonstration of Textile markup. + +* foo +* bar +* baz + +# foo +# bar +# baz + +

+perl code
+
+ +EOS + +use Text::Hatena; +use Text::Xatena; +use Text::Markdown; +use Text::Textile; + +my $thx = Text::Xatena->new; +my $markdown = Text::Markdown->new; +my $textile = Text::Textile->new; + +cmpthese(-1, { + 'Xatena' => sub { + my $html = $thx->format($text); + }, + 'Hatena' => sub { + my $html = Text::Hatena->parse($text); + }, + 'Markdown' => sub { + my $html = $markdown->markdown($text); + }, + 'Textile' => sub { + my $html = $textile->process($text); + }, +}); + +__END__ +Rate Hatena Textile Markdown Xatena +Hatena 26.8/s -- -84% -86% -89% +Textile 171/s 537% -- -8% -27% +Markdown 186/s 594% 9% -- -20% +Xatena 233/s 770% 37% 25% -- +