Skip to content

Commit

Permalink
Merge branch 'doc'
Browse files Browse the repository at this point in the history
  • Loading branch information
sebfisch committed Mar 5, 2010
2 parents 186c8aa + 7490697 commit 0c2fe47
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,10 @@ summary files generated by criterion. To demonstrate the criterion
mode, we write a small Haskell program that benchmarks a simple
definition of the [factorial] function:

~~~ { .Haskell }
import Criterion.Main
main = defaultMain [bgroup "fac" [bench (show n) (nf product [1..n]) | n <- ns]]
where ns = [10^4 * k | k <- [1,2,3]] :: [Integer]
~~~
import Criterion.Main

main = defaultMain [bgroup "fac" [bench (show n) (nf product [1..n]) | n <- ns]]
where ns = [10^4 * k | k <- [1,2,3]] :: [Integer]

We can compile this program, generate a benchmark summary using
criterion, and visualise it using barchart as follows:
Expand All @@ -196,10 +194,8 @@ We can now modify the program to use an explicitly recursive
definition of the fibonacci function to see whether this affects the
run times.

~~~ { .Haskell }
fac 0 = 1
fac n = n * fac (n-1)
~~~
fac 0 = 1
fac n = n * fac (n-1)

After generating another summary file `factorial2.csv` we could
generate another bar chart to visualise it and view both charts side
Expand Down Expand Up @@ -245,16 +241,14 @@ generate bar charts from CSV files generated by progression.
We can alter the factorial program as follows to generate
progression's data:

~~~ { .Haskell }
import Criterion
import Progression.Main
main = defaultMain (bgroup "fac" [bench (show n) (nf fac n) | n <- ns])
where ns = [10^4 * k | k <- [1,2,3]] :: [Integer]
fac 0 = 1
fac n = n * fac (n-1)
~~~
import Criterion
import Progression.Main

main = defaultMain (bgroup "fac" [bench (show n) (nf fac n) | n <- ns])
where ns = [10^4 * k | k <- [1,2,3]] :: [Integer]

fac 0 = 1
fac n = n * fac (n-1)

We do not need to change the fibonacci function itself because we
won't execute benchmarks using progression. We only generate a
Expand Down

0 comments on commit 0c2fe47

Please sign in to comment.