Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cat << EOT > pacotes
- python-4.3.5-1-x86_64.chi.zst
- python-zope-4.3.5-1-x86_64.chi.zst
- python-zope-proxy-4.3.5-1-x86_64.chi.zst
- xorg-server-xvfb-21.1.3-6-x86_64.chi.zst
- xorg-fonts-100dpi-1.0.3-7-any.chi.zst
- EOT
- split1()
- {
- file=$1
- RE='(.+)-(([^-]+)-([0-9]+))-([^.]+)\.chi\.zst'
- folder_dir=$(echo ${file%/*})
- fullname=$(echo ${file##*/})
- [[ $fullname == $folder_dir ]] && folder_dir=localhost
- [[ $fullname =~ $RE ]] &&
- {
- fullname=${BASH_REMATCH[0]}
- base=${BASH_REMATCH[1]}
- version_build=${BASH_REMATCH[2]}
- version=${BASH_REMATCH[3]}
- build=${BASH_REMATCH[4]}
- arch=${BASH_REMATCH[5]}
- base_version=$base-$version_build
- echo $folder_dir $fullname $arch $base $base_version $version-$build $build
- }
- }
- split2()
- {
- file=$1
- RE='(.+)-(([^-]+)-([0-9]+))-([^.]+)\.chi\.zst'
- folder_dir=${file%/*}
- fullname=${file##*/}
- [[ $fullname == $folder_dir ]] && folder_dir=localhost
- [[ $fullname =~ $RE ]] &&
- {
- fullname=${BASH_REMATCH[0]}
- base=${BASH_REMATCH[1]}
- version_build=${BASH_REMATCH[2]}
- version=${BASH_REMATCH[3]}
- build=${BASH_REMATCH[4]}
- arch=${BASH_REMATCH[5]}
- base_version=$base-$version_build
- echo $folder_dir $fullname $arch $base $base_version $version-$build $build
- }
- }
- s1(){ while read p1; do split1 $p1; done < pacotes; }
- s2(){ while read p2; do split2 $p2; done < pacotes; }
- benshmark()
- {
- local LC_ALL= LC_NUMERIC=C TIMEFORMAT=%lR L=$1 s; shift
- for s
- {
- echo -n "$s "
- time for ((i=0;i<L;i++)); { $s; } &> /dev/null
- }
- }
- $ echo -e "\ns1:"; s1 | column -ts' '
- s1:
- localhost python-4.3.5-1-x86_64.chi.zst x86_64 python python-4.3.5-1 4.3.5-1 1
- localhost python-zope-4.3.5-1-x86_64.chi.zst x86_64 python-zope python-zope-4.3.5-1 4.3.5-1 1
- localhost python-zope-proxy-4.3.5-1-x86_64.chi.zst x86_64 python-zope-proxy python-zope-proxy-4.3.5-1 4.3.5-1 1
- localhost xorg-server-xvfb-21.1.3-6-x86_64.chi.zst x86_64 xorg-server-xvfb xorg-server-xvfb-21.1.3-6 21.1.3-6 6
- localhost xorg-fonts-100dpi-1.0.3-7-any.chi.zst any xorg-fonts-100dpi xorg-fonts-100dpi-1.0.3-7 1.0.3-7 7
- $ echo -e "\ns2:"; s2 | column -ts' '
- s2:
- localhost python-4.3.5-1-x86_64.chi.zst x86_64 python python-4.3.5-1 4.3.5-1 1
- localhost python-zope-4.3.5-1-x86_64.chi.zst x86_64 python-zope python-zope-4.3.5-1 4.3.5-1 1
- localhost python-zope-proxy-4.3.5-1-x86_64.chi.zst x86_64 python-zope-proxy python-zope-proxy-4.3.5-1 4.3.5-1 1
- localhost xorg-server-xvfb-21.1.3-6-x86_64.chi.zst x86_64 xorg-server-xvfb xorg-server-xvfb-21.1.3-6 21.1.3-6 6
- localhost xorg-fonts-100dpi-1.0.3-7-any.chi.zst any xorg-fonts-100dpi xorg-fonts-100dpi-1.0.3-7 1.0.3-7 7
- $ benshmark 2000 s{1,2}
- s1 0m18.894s
- s2 0m1.073s
- $ bc <<< 'scale=3; 18.894/1.073'
- 17.608
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement