Permalink
Browse files

improved report; updated README

  • Loading branch information...
msoap committed Mar 18, 2012
1 parent 14d1171 commit b6b22a8d225b296cc88d87b0d36a693c86c68dbe
Showing with 72 additions and 37 deletions.
  1. +2 −1 .gitignore
  2. +27 −20 README.md
  3. +43 −16 create-report.pl
View
@@ -1,3 +1,4 @@
report.dat
fact_c
-chart.png
+chart*.png
+report.md
View
@@ -1,8 +1,8 @@
-Подсчет факториала на разных языках
-===================================
+Comparison of languages for speed by calculation of factorial in different languages
+====================================================================================
-Аппаратные средства:
---------------------
+Hardware:
+---------
Название модели: MacBook Pro
Идентификатор модели: MacBookPro7,1
@@ -83,19 +83,26 @@ AWK (20070501)
Report:
-------
-### text chart:
- luajit - 9972006 rps (x133) **********************************************************************
- C - 6812701 rps (x91 ) ***********************************************
- JavascriptCore - 4847180 rps (x65 ) **********************************
- node.js - 4439017 rps (x59 ) *******************************
- lua - 454555 rps (x6 ) ***
- python - 195261 rps (x2 ) *
- php - 185238 rps (x2 ) *
- perl - 115323 rps (x1 )
- ruby - 74500 rps (x1 )
-
-###all languages:
-![Chart for all languages](https://chart.googleapis.com/chart?cht=bhs&chs=800x200&chd=t%3A9972006%2C6812701%2C4847180%2C4439017%2C454555%2C195261%2C185238%2C115323%2C74500&chco=4d89f9&chbh=15&chds=0,9972006.58311987&chxt=x,y,r&chxl=1%3A%7Cruby%7Cperl%7Cphp%7Cpython%7Clua%7Cnode.js%7CJavascriptCore%7CC%7Cluajit%7C2%3A%7C74500%20rps%7C115323%20rps%7C185238%20rps%7C195261%20rps%7C454555%20rps%7C4439017%20rps%7C4847180%20rps%7C6812701%20rps%7C9972006%20rps%7C0%3A%7C0%20%25%7C10%20%25%7C20%20%25%7C30%20%25%7C40%20%25%7C50%20%25%7C60%20%25%7C70%20%25%7C80%20%25%7C90%20%25%7C100%20%25)
-
-###languages without JIT/compile:
-![Chart for slow languages](https://chart.googleapis.com/chart?cht=bhs&chs=800x130&chd=t%3A454555%2C195261%2C185238%2C115323%2C74500&chco=4d89f9&chbh=15&chds=0,454555.854232423&chxt=x,y,r&chxl=1%3A%7Cruby%7Cperl%7Cphp%7Cpython%7Clua%7C2%3A%7C74500%20rps%7C115323%20rps%7C185238%20rps%7C195261%20rps%7C454555%20rps%7C0%3A%7C0%20%25%7C10%20%25%7C20%20%25%7C30%20%25%7C40%20%25%7C50%20%25%7C60%20%25%7C70%20%25%7C80%20%25%7C90%20%25%7C100%20%25)
+###report all (Sun Mar 18 20:38:20 2012):
+
+ luajit - 9613216 rps: **********************************************************************
+ C - 6848418 rps: *************************************************
+ JavascriptCore - 4750887 rps: **********************************
+ node.js - 4486641 rps: ********************************
+ lua - 448643 rps: ***
+ python - 183658 rps: *
+ awk - 178267 rps: *
+ php - 171625 rps: *
+ perl - 113564 rps:
+ ruby - 73900 rps:
+ perl6 - 118 rps:
+
+![Chart for all all](https://chart.googleapis.com/chart?cht=bhs&chs=700x245&chd=t%3A9613216%2C6848418%2C4750887%2C4486641%2C448643%2C183658%2C178267%2C171625%2C113564%2C73900%2C118&chco=4d89f9&chbh=15&chds=0,9613216.09567688&chxt=x,y,r&chxl=1%3A%7Cperl6%7Cruby%7Cperl%7Cphp%7Cawk%7Cpython%7Clua%7Cnode.js%7CJavascriptCore%7CC%7Cluajit%7C2%3A%7C118%20rps%7C73900%20rps%7C113564%20rps%7C171625%20rps%7C178267%20rps%7C183658%20rps%7C448643%20rps%7C4486641%20rps%7C4750887%20rps%7C6848418%20rps%7C9613216%20rps%7C0%3A%7C0%20%25%7C10%20%25%7C20%20%25%7C30%20%25%7C40%20%25%7C50%20%25%7C60%20%25%7C70%20%25%7C80%20%25%7C90%20%25%7C100%20%25)
+
+###report fast (Sun Mar 18 20:38:30 2012):
+
+![Chart for all fast](https://chart.googleapis.com/chart?cht=bhs&chs=700x105&chd=t%3A9613216%2C6848418%2C4750887%2C4486641&chco=4d89f9&chbh=15&chds=0,9613216.09567688&chxt=x,y,r&chxl=1%3A%7Cnode.js%7CJavascriptCore%7CC%7Cluajit%7C2%3A%7C4486641%20rps%7C4750887%20rps%7C6848418%20rps%7C9613216%20rps%7C0%3A%7C0%20%25%7C10%20%25%7C20%20%25%7C30%20%25%7C40%20%25%7C50%20%25%7C60%20%25%7C70%20%25%7C80%20%25%7C90%20%25%7C100%20%25)
+
+###report other (Sun Mar 18 20:38:40 2012):
+
+![Chart for all other](https://chart.googleapis.com/chart?cht=bhs&chs=700x165&chd=t%3A448643%2C183658%2C178267%2C171625%2C113564%2C73900%2C118&chco=4d89f9&chbh=15&chds=0,448643.615756483&chxt=x,y,r&chxl=1%3A%7Cperl6%7Cruby%7Cperl%7Cphp%7Cawk%7Cpython%7Clua%7C2%3A%7C118%20rps%7C73900%20rps%7C113564%20rps%7C171625%20rps%7C178267%20rps%7C183658%20rps%7C448643%20rps%7C0%3A%7C0%20%25%7C10%20%25%7C20%20%25%7C30%20%25%7C40%20%25%7C50%20%25%7C60%20%25%7C70%20%25%7C80%20%25%7C90%20%25%7C100%20%25)
View
@@ -22,6 +22,8 @@
}
);
+our %is_fast = map {$_ => 1} qw/luajit C JavascriptCore node.js/;
+
# ------------------------------------------------------------------------------
sub calc {
my %result;
@@ -61,44 +63,69 @@ sub calc {
# ------------------------------------------------------------------------------
sub create_report {
- print "Report:\n";
+ my ($name, $grep_sub) = @_;
my $VAR1;
open my $FH, '<', $report_data or die "Error open file: $!\n";
eval join('', <$FH>);
die "$report_data is not valid" if $@;
close $FH;
- # without fasters languages
- # delete $VAR1->{$_} for qw/luajit C JavascriptCore node.js/;
+ # grep by speed
+ my $stat = {map {$_ => $VAR1->{$_}}
+ grep {$grep_sub->($_)}
+ keys %$VAR1
+ };
+
+ my $max_rps = max(values %$stat);
+ my $min_rps = min(values %$stat);
+ my $result_report_md = '';
- my $max_rps = max(values %$VAR1);
- my $min_rps = min(values %$VAR1);
- for my $lang (sort {$VAR1->{$b} <=> $VAR1->{$a}} keys %$VAR1) {
- my $rps = $VAR1->{$lang};
+ print "Report $name:\n";
+ $result_report_md .= sprintf "###report $name (%s):\n\n", localtime() . "";
+ for my $lang (sort {$stat->{$b} <=> $stat->{$a}} keys %$stat) {
+ my $rps = $stat->{$lang};
my $gistogr_line = '*' x (70 * $rps / $max_rps);
- printf "%15s - %7i rps (x%-3i) %s\n", $lang, $rps, $rps / $min_rps, $gistogr_line;
+ printf "%15s - %7i rps: %s\n", $lang, $rps, $gistogr_line;
+ $result_report_md .= sprintf " %15s - %7i rps: %s\n", $lang, $rps, $gistogr_line;
}
+ $result_report_md .= "\n";
+ printf "\n";
# google image chart
- my $chd = "t:" . join ",", map {int($VAR1->{$_})} sort {$VAR1->{$b} <=> $VAR1->{$a}} keys %$VAR1;
+ my $chd = "t:" . join ",", map {int($stat->{$_})} sort {$stat->{$b} <=> $stat->{$a}} keys %$stat;
$chd = uri_escape($chd);
- my $chxl = "1:|" . join "|", sort {$VAR1->{$a} <=> $VAR1->{$b}} keys %$VAR1;
- $chxl .= "|2:|" . join "|", map {int($VAR1->{$_}) . ' rps'} sort {$VAR1->{$a} <=> $VAR1->{$b}} keys %$VAR1;
+ my $chxl = "1:|" . join "|", sort {$stat->{$a} <=> $stat->{$b}} keys %$stat;
+ $chxl .= "|2:|" . join "|", map {int($stat->{$_}) . ' rps'} sort {$stat->{$a} <=> $stat->{$b}} keys %$stat;
$chxl .= "|0:|" . join "|", map {$_ * 10 . " %"} 0 .. 10;
$chxl = uri_escape($chxl);
-
- my $url = "https://chart.googleapis.com/chart?cht=bhs&chs=1000x200&chd=$chd&chco=4d89f9&chbh=15&chds=0,$max_rps&chxt=x,y,r&chxl=$chxl";
- print "\n$url\n";
+ my $height_one = 15;
+ my $height = scalar(1 + keys %$stat) * ($height_one + 5) + 5;
+ my $width = 700;
+
+ my $url = "https://chart.googleapis.com/chart?cht=bhs&chs=${width}x$height&chd=$chd&chco=4d89f9&chbh=$height_one&chds=0,$max_rps&chxt=x,y,r&chxl=$chxl";
+ $result_report_md .= "![Chart for all $name]($url)\n\n";
system("open", $url) if $^O eq 'darwin';
- system("curl -s '$url' > chart.png");
+ system("curl -s '$url' > chart_$name.png");
+
+ return $result_report_md;
}
# ------------------------------------------------------------------------------
sub main {
die "$0 [ --help | --calc | --create ]\n" if $ARGV[0] && $ARGV[0] eq '--help';
calc() if ! @ARGV || $ARGV[0] eq '--calc';
- create_report() if ! @ARGV || $ARGV[0] eq '--create';
+
+ if (! @ARGV || $ARGV[0] eq '--create') {
+ my $result_report_md = '';
+ $result_report_md .= create_report('all', sub () {1});
+ $result_report_md .= create_report('fast', sub () {$is_fast{$_[0]} ? 1 : 0});
+ $result_report_md .= create_report('other', sub () {$is_fast{$_[0]} ? 0 : 1});
+
+ open my $FHR, '>', 'report.md' or die "Error open file: $!\n";
+ print $FHR $result_report_md;
+ close $FHR;
+ }
}
# ------------------------------------------------------------------------------

0 comments on commit b6b22a8

Please sign in to comment.