Skip to content

Commit

Permalink
Adding .bib test file
Browse files Browse the repository at this point in the history
  • Loading branch information
WGUNDERWOOD committed May 2, 2024
1 parent fe2fc73 commit 788567d
Show file tree
Hide file tree
Showing 5 changed files with 2,639 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "tex-fmt"
license = "MIT"
version = "0.1.0"
edition = "2021"
description = "LaTeX formatter written in Rust."
description = "LaTeX formatter written in Rust"

[dependencies]
clap = { version = "=4.4.0", features = ["derive"] }
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ E = m c^2
- 🔧 No configuration necessary
- 📟 Command-line interface
- 📜 Handles LaTeX file types `.tex`, `.bib`, `.cls`, and `.sty`
- 🦀 Written entirely in safe Rust

## Installation

Expand All @@ -77,11 +78,11 @@ cargo install --git "https://github.com/wgunderwood/tex-fmt"
## Performance

Run `perf.sh` to format all test cases.
For large files, `tex-fmt` is hundreds of times faster than latexindent.
For large files, tex-fmt is hundreds of times faster than latexindent.

| **Files** | **Lines** | **Size** | **tex-fmt** | **latexindent** | **latexindent -m** |
| --- | --- | --- | --- | --- | --- |
| 11 | 30k | 800kb | **0.0362s** | 12.0s [x333] | 15.9s [x439] |
| 14 | 33k | 948kb | **0.0392s** | 14.5s [x369] | 18.7s [x478] |

## Limitations

Expand Down
16 changes: 9 additions & 7 deletions perf.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
DIR="$(mktemp -d)"
cp tests/*_in.tex $DIR
cp tests/*_in.* $DIR

echo "Test files:"
for f in $DIR/*.tex; do
for f in $DIR/*; do
echo -n " $(basename $f), "
echo -n "$(wc -l $f | cut --delimiter=" " --fields 1) lines, "
echo "$(ls -sh $f | cut --delimiter=" " --fields 1)"
done
echo -n "Total: $(ls -l $DIR/*.tex | wc -l) files, "
echo -n "$(wc -l --total=only $DIR/*.tex) lines, "

echo
echo -n "Total: $(ls -l $DIR/* | wc -l) files, "
echo -n "$(wc -l --total=only $DIR/*) lines, "
echo "$(ls -lh $DIR | head -n 1 | cut --delimiter=" " --fields 2)"
echo

hyperfine --warmup 2 \
-n "tex-fmt" "./target/release/tex-fmt $DIR/*.tex" \
-n "latexindent" "latexindent $DIR/*.tex" \
-n "latexindent -m" "latexindent -m $DIR/*.tex"
-n "tex-fmt" "./target/release/tex-fmt $DIR/*" \
-n "latexindent" "latexindent $DIR/*" \
-n "latexindent -m" "latexindent -m $DIR/*"
Loading

0 comments on commit 788567d

Please sign in to comment.