hykilpikonna / hyfetch

🏳️‍🌈 🏳️‍⚧️ Neofetch with LGBTQ+ pride flags!
MIT License
1.27k stars 96 forks source link

Performance of reset #158

Closed Glandos closed 1 year ago

Glandos commented 1 year ago

Describe the bug

Since #101 the reset variable in neofetch was changed to \e[39;22m, to only reset colors. When drawing colored bars, performance dropped drastically. On my system, it has dropped from 253ms to 1.1s.

Expected behavior

Performance should not drop drastically when resetting colors.

Screenshots

With actual reset variable

~ ⏰6s574ms❯ /tmp/hyfetch/bin/neowofetch
10.35.203.168 user@poulpe 
─────────────────────────── 
OS > Debian GNU/Linux trixie/sid 🐧 > 6.3.0-1-amd64 
Uptime > 2 days, 21 hours, 49 mins 
Server > Latitude 5590 Intel i7-8650U (8) @ 4.2GHz 
Memory > [🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋] 17.43 GiB / 31.20 GiB (55%) 
/ > [🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋] 170G / 459G (40%) 
/mnt/public > [🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋] 940G / 1.7T (57%) 

~ ❯ hyperfine /tmp/hyfetch/bin/neowofetch
Benchmark 1: /tmp/hyfetch/bin/neowofetch
  Time (mean ± σ):      1.137 s ±  0.046 s    [User: 1.066 s, System: 0.074 s]
  Range (min … max):    1.086 s …  1.224 s    10 runs

With reset variable set to \e[0m:

~ ⏰11s434ms❯ /tmp/hyfetch/bin/neowofetch
10.35.203.168 user@poulpe 
─────────────────────────── 
OS > Debian GNU/Linux trixie/sid 🐧 > 6.3.0-1-amd64 
Uptime > 2 days, 21 hours, 49 mins 
Server > Latitude 5590 Intel i7-8650U (8) @ 4.2GHz 
Memory > [🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋] 17.43 GiB / 31.20 GiB (55%) 
/ > [🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋] 170G / 459G (40%) 
/mnt/public > [🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋🬋] 940G / 1.7T (57%) 

~ ❯ hyperfine /tmp/hyfetch/bin/neowofetch
Benchmark 1: /tmp/hyfetch/bin/neowofetch
  Time (mean ± σ):     253.9 ms ±  10.5 ms    [User: 181.3 ms, System: 76.3 ms]
  Range (min … max):   241.3 ms … 272.7 ms    10 runs

Config file

N/A

Additional context

I'm using Tilix on Xfce. bars_border="on" trigger the bug, since it calls $(color fg) which itself prints ${reset} using printf. Setting bars_border="off" is a small workaround, but to get full performance, \e[0m is the best choice.

hykilpikonna commented 1 year ago

image

image

I'm also getting consistent result that using \e[0m is faster.