Skip to content

Commit

Permalink
Merge 03db117 into 0145694
Browse files Browse the repository at this point in the history
  • Loading branch information
harendra-kumar committed Apr 30, 2020
2 parents 0145694 + 03db117 commit ae1514c
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 32 deletions.
29 changes: 5 additions & 24 deletions benchmark/Chart.hs
Expand Up @@ -11,37 +11,18 @@ selectBench :: (SortColumn -> Either String [(String, Double)]) -> [String]
selectBench f =
-- reverse
fmap fst
$ either error (sortOn snd) $ f $ ColumnIndex 0
$ either error (sortOn fst) $ f $ ColumnIndex 0

main :: IO ()
main = do
let icu = "Normalize NFD/text-icu/"
let utrans = "Normalize NFD/unicode-transforms/"

let icu1 = "text-icu/NFD/"
let utrans1 = "unicode-transforms/NFD/"
let utf8proc1 = "utf8proc/NFD/"

let utrans2 = "unicode-transforms-text/NFD/"

let cfg = defaultConfig
{ classifyBenchmark = \bs ->
case stripPrefix icu bs of
case stripPrefix "text-icu/" bs of
Just x -> Just ("ICU", x)
Nothing ->
case stripPrefix icu1 bs of
Just x -> Just ("ICU", x)
Nothing ->
case stripPrefix utrans bs of
Just x -> Just ("unicode-transforms",x)
Nothing ->
case stripPrefix utrans1 bs of
Just x -> Just ("unicode-transforms",x)
Nothing ->
case stripPrefix utrans2 bs of
Just x -> Just ("unicode-transforms",x)
Nothing ->
fmap ("utf8proc",) $ stripPrefix utf8proc1 bs
case stripPrefix "unicode-transforms-text/" bs of
Just x -> Just ("unicode-transforms",x)
Nothing -> error "unknown benchmark"
, selectBenchmarks = selectBench
, presentation = Groups PercentDiff
}
Expand Down
61 changes: 53 additions & 8 deletions benchmark/README.md
@@ -1,21 +1,66 @@
# Comparing benchmarks for regression

Build and run the benchmark executable with `--csvraw=results.csv` option for
the baseline code i.e. without the changes.
The following commands are tested with `cabal` version 3.0.

Run the benchmarks for the baseline code i.e. without the changes:

```
$ cabal v2-run bench -- --csvraw=results.csv unicode-transforms
# Remove any old benchmark results file first
$ rm results.csv
$ cabal run bench -- --csvraw=results.csv --quick
```

It will collect the benchmark results in `results.csv` file.

Now repeat the above step for the new code i.e. with the changes.
It will append the benchmarks results to the existing csv file.
It will append the new benchmarks results to the existing `results.csv` file.

If you want the benchmarks to run quickly for a quick overview then use
`--quick` option when running the benchmarking executable.
If you want more accurate benchmark results remove the `--quick` flag.

Build the bench-show reporting executable `chart`.
To generate a benchmark comparison between old and new changes from the
benchmark results in `results.csv` file:

```
# [NOTE] The path "results.csv" is harcoded in the chart executable.
$ cabal v2-run chart
$ cabal run chart --flag bench-show
```

# Comparing with ICU (text-icu package)

Install the icu library:

```
# On Mac OS using MacPorts
$ sudo port install icu
# On Mac OS using brew
$ brew install icu4c
# On Debian Linux based distributions (the library version suffix may differ)
$ sudo apt-get install libicu65
```

If cabal cannot automatically find the icu library (e.g. when installed
via macports install) then use explicit `LIBRARY_PATH` to tell it where
the library is:

```
$ export LIBRARY_PATH=/usr/lib/:opt/local/lib
# Alternatively, pass the lib and include path as follows
$ cabal bench --extra-lib-dirs=/usr/local/opt/icu4c/lib --extra-include-dirs=/usr/local/opt/icu4c/include
```

Remove any old `results.csv` and run benchmarks with `has-icu` flag enabled:

```
$ rm results.csv
$ cabal run bench --flag has-icu -- --csvraw=results.csv --quick
```

The following command will now show the comparison between `text-icu` and
`unicode-transforms`:

```
$ cabal run chart --flag bench-show
```
17 changes: 17 additions & 0 deletions unicode-data/README.md
Expand Up @@ -20,3 +20,20 @@ utility and run it like this:
```
ucd2haskell ucdxml/ucd.all.flat.xml ../Data/Unicode/Properties/
```

Update the unicode version in the changelog below as well as in the top
level README and haddock docs.

## Changelog

### 0.3.6

* Unicode 12.1.0: https://www.unicode.org/Public/12.1.0/ucdxml/

### 0.3.0

* Unicode 9.0.0: https://www.unicode.org/Public/9.0.0/

### 0.2.0

* Unicode 8.0.0: https://www.unicode.org/Public/8.0.0/

0 comments on commit ae1514c

Please sign in to comment.