#!/bin/sh export PYTHONPATH=${HOME}/src/pkgcore:${PYTHONPATH} export PATH=${HOME}/src/pkgcore/bin:${PATH} REPO="${REPO:-/mnt/scratch/portage}" uncached_run() { echo "uncached: $*" for x in 1 2; do sudo sync echo 3 | sudo tee /proc/sys/vm/drop_caches > /dev/null { time ${*} &> /dev/null; } 2>&1 done } cached_run() { echo "cached: $*" $* &> /dev/null for x in 1 2 3; do { time $* &> /dev/null; } 2>&1 done } cat_bench() { echo echo "cat search" echo echo for command in \ "paludis --list-packages --category dev-util" \ "pquery -nv -m dev-util/* --raw" \ "emerge -s @dev-util/" do uncached_run "$command" echo cached_run "$command" echo done } pkg_bench() { echo echo "categoryless lookups" echo for command in \ "paludis -q bsdiff xorg-server" \ "pquery -nv -m bsdiff -m xorg-server" \ "emerge -s bsdiff xorg-server" do uncached_run "$command" echo cached_run "$command" echo done } atom_bench() { echo echo "full atom lookups" echo for command in \ "paludis -q dev-util/bsdiff x11-base/xorg-server" \ "pquery -nv -m dev-util/bsdiff -m x11-base/xorg-server" \ "emerge -s dev-util/bsdiff x11-base/xorg-server" do uncached_run "$command" echo cached_run "$command" echo done } deep_system_bench() { echo echo "resolving deep system upgrade" echo for command in \ "paludis -pi system" \ "pmerge -Dups system" \ "emerge -Dup system" do uncached_run "$command" echo cached_run "$command" echo done } deep_world_system_bench() { echo echo "resolving deep world/system upgrade" echo for command in \ "paludis -pi world" \ "pmerge -Dups world -s system" \ "emerge -Dup world" do uncached_run "$command" echo cached_run "$command" echo done } empty_system_bench() { echo echo "resolving empty system" echo for command in \ "paludis -pie system" \ "pmerge -Deps system" \ "emerge -Dep system" do uncached_run "$command" echo cached_run "$command" echo done } deep_kde_gnome_bench() { echo echo "resolving deep kde/gnome" echo for command in \ "paludis -pi kde gnome" \ "pmerge -Dup kde gnome" \ "emerge -Dup kde gnome" do uncached_run "$command" echo cached_run "$command" echo done } portdir_single_revdep_bench() { echo echo "revdep lookup" echo "note, pkgcore/paludis differ in their results" echo "pkgcore looks for any intersection; paludis looks for intersections intersecting the tree" echo for command in \ "adjutrix -r dev-lang/python --repository-dir ${REPO}" \ "pquery --revdep dev-lang/python --raw" do uncached_run "$command" echo cached_run "$command" echo done } vdb_single_revdep_bench() { echo echo "revdep lookup" echo "note, pkgcore/paludis differ in their results" echo "pkgcore looks for any intersection; paludis looks for intersections intersecting the tree" echo "finally, equery uses a db. it cheats, and stomps the others ass ;)" echo for command in \ "adjutrix -r dev-lang/python --repository-dir /var/db/pkg" \ "pquery --revdep dev-lang/python --vdb" \ "equery depends dev-lang/python" do uncached_run "$command" echo cached_run "$command" echo done } adjutrix_multiple_revdep() { local revdep for revdep in $*; do adjutrix -r $revdep --repository-dir ${REPO} done } portdir_multiple_revdep_bench() { echo echo "revdep lookup" echo "note, pkgcore/paludis differ in their results" echo "pkgcore looks for any intersection; paludis looks for intersections intersecting the tree" echo for command in \ "adjutrix_multiple_revdep dev-lang/python sys-apps/portage" \ "pquery --revdep dev-lang/python --revdep sys-apps/portage --raw" do uncached_run "$command" echo cached_run "$command" echo done } run_qualudis_deps_visible_check() { ( cd ${REPO}/$1; qualudis -c deps_visible; ) } qa_cat_profile_visibility_bench() { echo echo "check that all deps are visible for repo specified profiles" echo "note- repoman is excluded, since it cannot be told to run just this particular check" echo "finally, note paludis doesn't support package.provided, thus its results for profiles dependant on that addition" echo "(macos profiles primarily) are invalid." echo for command in \ "run_qualudis_deps_visible_check sys-apps" \ "pcheck -r ${REPO} -c visibility sys-apps/*" do uncached_run $command echo cached_run $command echo done } qa_pkg_profile_visibility_bench() { echo echo "check that all deps are visible for repo specified profiles" echo "note- repoman is excluded, since it cannot be told to run just this particular check" echo "finally, note paludis doesn't support package.provided, thus its results for profiles dependant on that addition" echo "(macos profiles primarily) are invalid." echo for command in \ "run_qualudis_deps_visible_check sys-devel/gcc" \ "pcheck -r ${REPO} -c visibility sys-devel/gcc" do uncached_run $command echo cached_run $command echo done } if [ ! -e "/proc/sys/vm/drop_caches" ]; then echo "can't do true cold caching since you're not running a >=2.6.16 kernel" echo "in other words, tests won't be accurate; this is part of the reason /proc/sys/vm/drop_caches was added" echo "any cold cache results you come up with be invalid, thus upgrade if you want to run this." exit 1 fi # check for cpufreq. freq='' for x in /sys/devices/system/cpu/cpu*; do [ ! -d "${x}/cpufreq" ] && continue if [ "$(cat "${x}/cpufreq/cpuinfo_min_freq" 2> /dev/null)" != "$(cat "${x}/cpufreq/cpuinfo_max_freq" 2> /dev/null)" ]; then if [ "$(< "${x}/cpufreq/scaling_governor")" != "performance" ]; then echo "$x cpufreq min does not match it's max; this can bias tests, especially fast hot cache tests"; echo "alternatively, force performance governer for tests" echo "lock the freqs down."; exit 2 fi fi if [ -z "${freq}" ]; then freq=$(cat "${x}/cpufreq/cpuinfo_max_freq" ) else if [ "${freq}" != "$(cat "${x}/cpufreq/cpuinfo_max_freq" )" ]; then echo "proc $x cpufreq max_freq differs from previously seen ${freq}" echo "this means test results can be variable depending upon which proc the job goes to" echo "either disable cpufreq, or force the procs all to the same speed" exit 3 fi fi done benchs="$(declare -F | sed -e 's:declare -[^ ]\+ ::' | grep '_bench$' | sort -g | sed -e 's:_bench$::')" for x in ${*:-${benchs}}; do echo "${x}" ${x}_bench done