version upgrade:

Optimized graphics driver function massively, knocked off about 60% of execution time by switching to a single read through via 
gawk..

In terms of dual core system, that saved literally about 1 second execution total time.
This commit is contained in:
inxi-svn 2011-06-13 22:31:22 +00:00
parent 8b297bd69e
commit 93b245e1af

54
inxi
View file

@ -1,8 +1,8 @@
#!/bin/bash
########################################################################
#### Script Name: inxi
#### version: 1.6.7
#### Date: June 10 2011
#### version: 1.6.8
#### Date: June 13 2011
#### Patch Number: 00
########################################################################
#### SPECIAL THANKS
@ -3505,30 +3505,42 @@ get_graphics_driver()
eval $LOGFS
# list is from sgfxi plus non-free drivers
local driver_list='apm ark ati chips cirrus cyrix fbdev fglrx glint i128 i740 intel i810 imstt mach64 mga neomagic nsc nv nvidia openchrome nouveau radeon radeonhd rendition s3 s3virge savage siliconmotion sis sisusb tdfx tga trident tseng unichrome vesa vga via voodoo vmware v4l'
local driver_list='apm|ark|ati|chips|cirrus|cyrix|fbdev|fglrx|glint|i128|i740|intel|i810|imstt|mach64|mga|neomagic|nsc|nv|nvidia|openchrome|nouveau|radeon|radeonhd|rendition|s3|s3virge|savage|siliconmotion|sis|sisusb|tdfx|tga|trident|tseng|unichrome|vesa|vga|via|voodoo|vmware|v4l'
local driver='' driver_string='' xorg_log_data='' status='' temp_array=''
if [[ $B_XORG_LOG == 'true' ]];then
xorg_log_data="$( cat $FILE_XORG_LOG )"
A_GRAPHIC_DRIVERS=( $(
for driver in $driver_list
do
# note there appears to be different unload/failed syntax, so using simple conservative one
if [[ -n $( grep -s "[[:space:]]Loading.*${driver}_drv.so" <<< "$xorg_log_data" ) ]];then
if [[ -n $( grep -si "Failed.*${driver}_drv.so" <<< "$xorg_log_data" ) ]];then
status='failed'
# can be Unloading driver OR Unloading /usr/lib/xorg/modules/drivers/driver_drv.so
elif [[ -n $( grep -Esi "Unloading[[:space:]](${driver}|.*${driver}_drv.so)$" <<< "$xorg_log_data" ) ]];then
status='unloaded'
else
status='loaded'
fi
driver_string="$driver,$status"
echo $driver_string
fi
done
gawk '
BEGIN {
i=0
driver=""
}
/[[:space:]]Loading.*('"$driver_list"')_drv.so$/ {
driver=gensub(/.*[[:space:]]Loading.*('"$driver_list"')_drv.so/, "\\1", 1, $0 )
# we get all the actually loaded drivers first, we will use this to compare the
# failed/unloaded, which have not always actually been truly loaded
aDrivers[driver]="loaded"
}
/Unloading[[:space:]].*('"$driver_list"')(|_drv.so)$/ {
driver=gensub(/(.*)Unloading[[:space:]].*('"$driver_list"')(|_drv.so)$/, "\\2", 1, $0 )
# we need to make sure that the driver has already been truly loaded, not just discussed
if ( driver in aDrivers ) {
aDrivers[driver]="unloaded"
}
}
/Failed.*('"$driver_list"')_drv.so$/ {
driver=gensub(/(.*)Failed.*('"$driver_list"')_drv.so$/, "\\2", 1, $0 )
# we need to make sure that the driver has already been truly loaded, not just discussed
if ( driver in aDrivers ) {
aDrivers[driver]="failed"
}
}
END {
for ( var in aDrivers ) {
print var "," aDrivers[var]
}
}' < $FILE_XORG_LOG
) )
xorg_log_data='' # dump from ram, does it matter?
fi
temp_array=${A_GRAPHIC_DRIVERS[@]}
log_function_data "A_GRAPHIC_DRIVERS: $temp_array"