-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
103 additions
and
31 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
| Command | Mean [s] | Min [s] | Max [s] | Relative | | ||
|:---|---:|---:|---:|---:| | ||
| `jsonian-mode` | 2.222 ± 0.007 | 2.213 | 2.239 | 1.68 ± 0.01 | | ||
| `json-mode` | 3.689 ± 0.102 | 3.622 | 3.910 | 2.78 ± 0.08 | | ||
| `javascript-mode` | 13.138 ± 0.062 | 13.042 | 13.224 | 9.91 ± 0.07 | | ||
| `fundamental-mode` | 1.325 ± 0.007 | 1.320 | 1.341 | 1.00 | | ||
| `prog-mode` | 1.396 ± 0.005 | 1.392 | 1.406 | 1.05 ± 0.01 | |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env sh | ||
|
||
# EMACS should be set to the binary to invoke. | ||
# FILE should be set to the file to test against. | ||
|
||
bench() { | ||
echo "$EMACS -Q --batch -nw \ | ||
-L . -L ../json-mode -L ../json-snatcher -L ../json-reformat \ | ||
--eval '(setq enable-local-variables nil)' \ | ||
--eval '(setq large-file-warning-threshold nil)' \ | ||
--eval '(switch-to-buffer (find-file-literally \"$FILE\"))' \ | ||
--eval \"$1\" \ | ||
--eval '(condition-case err \ | ||
(with-current-buffer (current-buffer) \ | ||
(setq font-lock-major-mode nil) \ | ||
(syntax-ppss-flush-cache -1) \ | ||
(font-lock-set-defaults) \ | ||
(save-excursion \ | ||
(font-lock-fontify-region (point-min) (point-max)))) \ | ||
((debug error) (kill-emacs (error-message-string err))))' \ | ||
--eval '(goto-char (point-max))' \ | ||
--eval '(kill-emacs)'" | ||
} | ||
|
||
hyperfine --export-markdown "$EXPORT" --show-output \ | ||
--command-name "fundamental-mode" "$(bench "(fundamental-mode)")" \ | ||
--command-name "prog-mode" "$(bench "(prog-mode)")" \ | ||
--command-name "jsonian-mode" "$(bench "(progn (require 'jsonian) (jsonian-mode))")" \ | ||
--command-name "json-mode" "$(bench "(progn (require 'json-mode) (json-mode))")" \ | ||
--command-name "javascript-mode" "$(bench "(javascript-mode)")" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
## Benchmarks | ||
|
||
The original reason I wrote jsonian is that I needed to read and naviage very large JSON | ||
files, and Emacs was slowing me down. To keep jsonian fast, I maintain benchmarks of | ||
jsonian doing real world tasks. | ||
|
||
### `font-lock`ing a large buffer | ||
|
||
This benchmark opens a very large (42M) JSON file, then forces Emacs to fontify it. It | ||
finally moves point to the end of the file and exits. | ||
|
||
| Command | Mean [s] | Min [s] | Max [s] | Relative | | ||
|:---|---:|---:|---:|---:| | ||
| `jsonian-mode` | 2.222 ± 0.007 | 2.213 | 2.239 | 1.68 ± 0.01 | | ||
| `json-mode` | 3.689 ± 0.102 | 3.622 | 3.910 | 2.78 ± 0.08 | | ||
| `javascript-mode` | 13.138 ± 0.062 | 13.042 | 13.224 | 9.91 ± 0.07 | | ||
| `fundamental-mode` | 1.325 ± 0.007 | 1.320 | 1.341 | 1.00 | | ||
| `prog-mode` | 1.396 ± 0.005 | 1.392 | 1.406 | 1.05 ± 0.01 | |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env sh | ||
|
||
MESSAGE=$(cat <<-EOF | ||
## Benchmarks | ||
The original reason I wrote jsonian is that I needed to read and naviage very large JSON | ||
files, and Emacs was slowing me down. To keep jsonian fast, I maintain benchmarks of | ||
jsonian doing real world tasks. | ||
### \`font-lock\`ing a large buffer | ||
This benchmark opens a very large (42M) JSON file, then forces Emacs to fontify it. It | ||
finally moves point to the end of the file and exits. | ||
$(sed 's/Command/Package/g' < bench/font-lock.md) | ||
We can use this benchmark to derive how long different parts of the proces take. | ||
- Fundamental mode is the lower limit. This is the time Emacs spends processing the | ||
buffer, parsing sexps, etc. | ||
- We see that \`prog-mode\` doesn't do much more then \`fundamental-mode\`, which makes | ||
sense. | ||
- Applying JSON formatting take at most \`jsonian-mode\` - \`prog-mode\`. | ||
Notes: | ||
- Both \`jsonian\` and \`json-mode\` were byte-compiled for the benchmark. | ||
EOF | ||
) | ||
|
||
echo "$MESSAGE" > "$EXPORT" |