Skip to content

Commit daf30ec

Browse files
committed
facilitate using samply; disable syntax-highlighting in bench.
Also remove process creation overhead.
1 parent 79b3035 commit daf30ec

File tree

5 files changed

+23
-6
lines changed

5 files changed

+23
-6
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ benches/pulldown-cmark
1010
benches/markdown-it
1111
/result
1212
/bench-output.md
13+
14+
benches/samply-bench-input.md
15+
/profile-*.json.gz

Makefile

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ bench:
1313
binaries: build-comrak-branch build-comrak-main build-cmark-gfm build-pulldown-cmark build-markdown-it
1414

1515
build-comrak-branch:
16-
cargo build --release
16+
cargo build --release --bin comrak --no-default-features --features cli
1717
cp ${ROOT}/target/release/comrak ${ROOT}/benches/comrak-${COMMIT}
1818

1919
build-comrak-main:
2020
git clone https://github.com/kivikakk/comrak.git --depth 1 --single-branch ${ROOT}/vendor/comrak || true
2121
cd ${ROOT}/vendor/comrak && \
22-
cargo build --release && \
22+
cargo build --release --bin comrak --no-default-features --features cli && \
2323
cp ./target/release/comrak ${ROOT}/benches/comrak-main
2424

2525
build-cmark-gfm:
@@ -54,3 +54,16 @@ bench-all: binaries
5454
hyperfine --warmup 10 --min-runs ${MIN_RUNS} -L binary comrak-${COMMIT},comrak-main,pulldown-cmark,cmark-gfm,markdown-it './bench.sh ./{binary}' --export-markdown ${ROOT}/bench-output.md &&\
5555
echo "\n\nRun on" `date -u` >> ${ROOT}/bench-output.md
5656

57+
benches/samply-bench-input.md:
58+
cat ${ROOT}/vendor/progit/*/*/*.markdown > $@
59+
60+
SAMPLY_OPTIONS:=-r 10000 --iteration-count 20 --reuse-threads
61+
SAMPLY_COMRAK_ARGS:=--syntax-highlighting none benches/samply-bench-input.md -o /dev/null
62+
63+
samply-comrak-branch: benches/samply-bench-input.md build-comrak-branch
64+
cat ${ROOT}/vendor/progit/*/*/*.markdown > benches/samply-bench-input.md
65+
samply record -o profile-branch.json.gz ${SAMPLY_OPTIONS} ${ROOT}/benches/comrak-${COMMIT} ${SAMPLY_COMRAK_ARGS}
66+
67+
samply-comrak-main: benches/samply-bench-input.md build-comrak-main
68+
cat ${ROOT}/vendor/progit/*/*/*.markdown > benches/samply-bench-input.md
69+
samply record -o profile-main.json.gz ${SAMPLY_OPTIONS} -P 3001 ${ROOT}/benches/comrak-main ${SAMPLY_COMRAK_ARGS}

benches/bench.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#! /bin/bash
22

3-
PROG=$1
3+
PROG="$1"
44
ROOTDIR=$(git rev-parse --show-toplevel)
55

6-
for lang in ar az be ca cs de en eo es es-ni fa fi fr hi hu id it ja ko mk nl no-nb pl pt-br ro ru sr th tr uk vi zh zh-tw; do \
7-
cat $ROOTDIR/vendor/progit/$lang/*/*.markdown | $PROG > /dev/null
8-
done
6+
cat $ROOTDIR/vendor/progit/*/*/*.markdown | "$PROG" > /dev/null

flake.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@
100100
clippy
101101
cargo-fuzz
102102
cargo-nextest
103+
cargo-flamegraph
104+
samply
103105
python3
104106
re2c
105107
hyperfine

src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ fn main() -> Result<(), Box<dyn Error>> {
320320
#[cfg(feature = "syntect")]
321321
let adapter: SyntectAdapter;
322322

323+
#[cfg_attr(not(feature = "syntect"), allow(unused_mut))]
323324
let mut plugins: Plugins = Plugins::default();
324325

325326
#[cfg(feature = "syntect")]

0 commit comments

Comments
 (0)