iinsertNameHere / catnap

A highly customizable systemfetch written in nim
https://catnap-fetch.xyz
MIT License
174 stars 10 forks source link

Optimizations #133

Closed yuki-was-taken closed 3 months ago

yuki-was-taken commented 3 months ago

Is your pull request linked to an existing issue?

132

What is your pull request about?:

  1. Added a few compile options to increase performance. As said in this comment, I think it should be safe to enable to danger flag, as any problems should be reported using the debug version.
  2. I added one line to flush stdout in the colors file.
  3. Made all the constants static.

Any other disclosures/notices/things to add?

There is definitely a performance increase of a few milliseconds, on my system it's 2 ms using debug mode, and on hyperfine the results are even faster on release mode.

Benchmark 1: ./bin/catnap
  Time (mean ± σ):       2.0 ms ±   0.1 ms    [User: 1.4 ms, System: 0.5 ms]
  Range (min … max):     1.7 ms …   2.5 ms    1354 runs