Powerlevel9k / powerlevel9k

Powerlevel9k was a tool for building a beautiful and highly functional CLI, customized for you. P9k had a substantial impact on CLI UX, and its legacy is now continued by P10k.
https://github.com/romkatv/powerlevel10k
MIT License
13.46k stars 949 forks source link

[Performance] PL9K is terribly slow #1382

Open Martmists-GH opened 4 years ago

Martmists-GH commented 4 years ago

Your Hardware

512GB PCIe NVMe Three Layer Cell SSD

Virtualization

Native Linux (Arch x86_64)

Terminal

Termite (latest)

How Fast is Fast

********************************************************************
                      Prompt Benchmark Results
********************************************************************
Warmup duration      8s
Benchmark duration   5.442s
Benchmarked prompts  1
Time per prompt      5442.32ms  <-- prompt latency (lower is better)
********************************************************************

Root cause seems to be the battery prompt. Settings:

POWERLEVEL9K_BATTERY_BACKGROUND="black"
POWERLEVEL9K_BATTERY_LOW_FOREGROUND="red"
POWERLEVEL9K_BATTERY_CHARGING_FOREGROUND="yellow"
POWERLEVEL9K_BATTERY_CHARGED_FOREGROUND="green"
POWERLEVEL9K_BATTERY_DISCONNECTED_FOREGROUND="green"
POWERLEVEL9K_BATTERY_LOW_THRESHOLD=15
POWERLEVEL9K_BATTERY_VERBOSE=false
POWERLEVEL9K_BATTERY_STAGES=('\uf244 ' '\uf243 ' 
                             '\uf243 ' '\uf243 ' 
                             '\uf242 ' '\uf242 ' 
                             '\uf241 ' '\uf241 ' 
                             '\uf241 ' '\uf240 ')

Cause seems to be acpi -b being slow, unknown why.

romkatv commented 4 years ago

Back in 2008 there was an app for iPhone called I Am Rich. It costed $999.99 and didn't do anything.

The application is described as "a work of art with no hidden function at all", with its only purpose being to show other people that they were able to afford it.

I had a similar idea for prompt segments that would do nothing useful except expressing users' virtues. By sporting I Am Generous segment in your prompt you can show everyone how generous you are with screen real estate. Do you have laid back personality, living an unhurried life? Let everyone know with I Am Patient segment that takes 5 seconds to load. Send the supercharged I Am Generous AND Patient message with the exclusive battery segment!

Syphdias commented 4 years ago

I don't know why acpi -b is slow. As far as I understand its doings it mainly reads a few files from your sysfs (which is not located on any disk but in memory). The requirement for acpi was removed on the next branch and replaced with reading exactly those files needed for identifying battery status directly. I'm not clear on the timeline of merging next into master.

Could you test if you are having the same slowdown issue with the battery segment on next?

@romkatv Maybe you could open a pull request to add such a segment? I'm sure it would be of great value for lots of people :laughing:.