Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add --no-syntax option #3102

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add --no-syntax option #3102

wants to merge 2 commits into from

Conversation

MoSal
Copy link

@MoSal MoSal commented Oct 9, 2024

When using plain output, calls to highlight_regions_for_line()
may cause a lot of overhead for little gain.

So add a new option --no-syntax that skips syntax highlighting.
It only has effect for plain output.

This change is made in a way that preserves backwards compatibility and
doesn't break any tests.

Here is a test-case.

Without --no-syntax

Benchmark 1: seq 10000000 | ./target/release/bat -pf
 Time (mean ± σ):      7.899 s ±  0.195 s    [User: 7.962 s, System: 0.076 s]
 Range (min … max):    7.587 s …  8.095 s    10 runs

With --no-syntax

Benchmark 1: seq 10000000 | ./target/release/bat -pf --no-syntax
 Time (mean ± σ):     636.7 ms ±  42.9 ms    [User: 696.8 ms, System: 41.2 ms]
 Range (min … max):   603.5 ms … 715.5 ms    10 runs

MoSal added 2 commits October 9, 2024 09:36
Before

```
Benchmark 1: seq 10000000 | bat
  Time (mean ± σ):      6.235 s ±  0.052 s    [User: 3.664 s, System: 2.714 s]
  Range (min … max):    6.172 s …  6.355 s    10 runs
```

After

```
Benchmark 1: seq 10000000 | ./target/release/bat
  Time (mean ± σ):     215.9 ms ±   5.1 ms    [User: 275.4 ms, System: 38.8 ms]
  Range (min … max):   210.3 ms … 224.9 ms    10 runs
```

Using `less` for comparison

```
Benchmark 1: seq 10000000 | less
  Time (mean ± σ):     637.3 ms ±  43.3 ms    [User: 642.1 ms, System: 95.6 ms]
  Range (min … max):   584.5 ms … 700.1 ms    10 runs
```

And raw

```
Benchmark 1: seq 10000000
  Time (mean ± σ):      63.1 ms ±   1.3 ms    [User: 57.1 ms, System: 5.9 ms]
  Range (min … max):    62.1 ms …  66.0 ms    10 runs
```

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
 When using plain output, calls to `highlight_regions_for_line()`
 may cause a lot of overhead for little gain.

 So add a new option `--no-syntax` that skips syntax highlighting.
 It only has effect for plain output.

 This change is made in a way that preserves backwards compatibility and
 doesn't break any tests.

 Here is a test-case.

 Without `--no-syntax`

 ```
 Benchmark 1: seq 10000000 | ./target/release/bat -pf
  Time (mean ± σ):      7.899 s ±  0.195 s    [User: 7.962 s, System: 0.076 s]
  Range (min … max):    7.587 s …  8.095 s    10 runs
 ```

 With `--no-syntax`

 ```
 Benchmark 1: seq 10000000 | ./target/release/bat -pf --no-syntax
  Time (mean ± σ):     636.7 ms ±  42.9 ms    [User: 696.8 ms, System: 41.2 ms]
  Range (min … max):   603.5 ms … 715.5 ms    10 runs
 ```

Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
@MoSal
Copy link
Author

MoSal commented Oct 9, 2024

Numbers above are with the buffer writer change applied from #3101. Without both, we get:

Benchmark 1: seq 10000000 | bat -pf
  Time (mean ± σ):     13.577 s ±  0.052 s    [User: 10.915 s, System: 2.797 s]
  Range (min … max):   13.519 s … 13.684 s    10 runs

@MoSal MoSal changed the title No syntax new Add --no-syntax option Oct 9, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant