summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar/X11/Bitmap.hs
diff options
context:
space:
mode:
authorTomas Janousek <tomi@nomi.cz>2019-10-28 22:59:31 +0100
committerTomas Janousek <tomi@nomi.cz>2019-10-28 23:22:04 +0100
commit74df93eaa2da360af6593fe473698d211370de15 (patch)
tree0d7767126520849c66fa3e4a9872614458e91ead /src/Xmobar/X11/Bitmap.hs
parent8c296301d4b9483a0501939def0449185842699a (diff)
downloadxmobar-74df93eaa2da360af6593fe473698d211370de15.tar.gz
xmobar-74df93eaa2da360af6593fe473698d211370de15.tar.bz2
Optimize Net a bit (noticeably less CPU/power usage)
- use strict ByteString as the Lazy version of readFile allocates a 32k buffer even though we usually need much less (isUp needs a few bytes) - refactor NetDev datatype and use unsafeInterleaveIO in isUp to avoid reading the operstate file entirely if we're not interested in that device - postpone ByteString unpacking in netParser to shave off some cycles, and avoid ByteString unpacking in isUp entirely On my system with 8 network devices (and more if docker is up), this seems to reduce xmobar's CPU usage noticeably. I have two "Run Network" in xmobar configuration, for eth and wlan, so without these changes, xmobar would evaluate isUp 16 times a second, and each evaluation would allocate a buffer for the IO Handle and then another buffer for the lazy ByteString readFile. Now it only does isUp once for every device I'm interested in, and the only large buffers allocated are the IO Handle ones (getting rid of these isn't worth the code complexity).
Diffstat (limited to 'src/Xmobar/X11/Bitmap.hs')
0 files changed, 0 insertions, 0 deletions