Skip to content

xrandr: exit earlier with --list(monitors|active-monitors-providers)

Exception for --version, all the remaining code seems useless as the results are not used to display anything. This improves the speed of xrandr --current --list-monitors --list-providers.

Before:

$ time xrandr --current --listmonitors --listproviders
Providers: number : 1
Provider 0: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 3 outputs: 7 associated providers: 0 name:modesetting
Monitors: 2
 0: +*DP-1-2 1920/510x1080/290+0+0  DP-1-2
 1: +DP-1-3 1920/510x1080/290+1920+0  DP-1-3
xrandr --current --listmonitors --listproviders  0.00s user 0.01s system 2% cpu 0.391 total

After:

$ time ./xrandr --current --listmonitors --listproviders
Providers: number : 1
Provider 0: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 3 outputs: 7 associated providers: 0 name:modesetting
Monitors: 2
 0: +*DP-1-2 1920/510x1080/290+0+0  DP-1-2
 1: +DP-1-3 1920/510x1080/290+1920+0  DP-1-3
./xrandr --current --listmonitors --listproviders  0.00s user 0.00s system 54% cpu 0.005 total

Merge request reports

Loading