Created
December 17, 2008 12:18
-
-
Save gugod/37042 to your computer and use it in GitHub Desktop.
Benchmarking Markapl and Tempate::Declare
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use lib '.'; | |
use lib '/Users/gugod/git/Markapl/lib'; | |
use lib 'lib'; | |
# use Benchmark::Forking qw( cmpthese ); | |
use Benchmark qw( cmpthese ); | |
use MyTDView; | |
use Template::Declare; | |
Template::Declare->init( roots => [ MyTDView ]); | |
use Template::Declare::Tags; | |
use MyMarkaplView; | |
cmpthese( | |
10000, | |
{ | |
'printf' => sub { "<p>Hello</p>"; }, | |
'Markapl 1' => sub { MyMarkaplView->render("test1"); }, | |
'Markapl 2' => sub { MyMarkaplView->render("test2"); }, | |
'Markapl 3' => sub { MyMarkaplView->render("test3"); }, | |
'Markapl 4' => sub { MyMarkaplView->render("test3"); }, | |
'TD 1' => sub { Template::Declare->show("test1"); }, | |
'TD 2' => sub { Template::Declare->show("test2"); }, | |
'TD 3' => sub { Template::Declare->show("test3"); }, | |
'TD 4' => sub { Template::Declare->show("test4"); }, | |
'TD 5' => sub { Template::Declare->show("test4"); }, | |
} | |
); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package MyMarkaplView; | |
use strict; | |
use warnings; | |
use Markapl; | |
template test1 => sub { | |
p { "Hello" } | |
}; | |
template test2 => sub { | |
p (id => "test") { "Hello" } | |
}; | |
template test3 => sub { | |
p ("#test") { "Hello" } | |
}; | |
template test4 => sub { | |
my $class = "foo"; | |
for (0..3) { | |
div(class => "salut $class") { "Hello, $_" } | |
} | |
}; | |
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package MyTDView; | |
use strict; | |
use warnings; | |
use base 'Template::Declare'; | |
use Template::Declare::Tags; | |
template test1 => sub { | |
p { "Hello" } | |
}; | |
template test2 => sub { | |
p { attr { id => "test2" }; "Hello" } | |
}; | |
template test3 => sub { | |
p { id is "test2"; "Hello" } | |
}; | |
template test4 => sub { | |
with (id => "test2"), p { "Hello" } | |
}; | |
template test5 => sub { | |
my $class = "foo"; | |
for(0..3) { | |
with(class => "salut $_"), div { "Hello, $_" } | |
} | |
}; | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment