3b018dd88828ff4d87147b8f84cb273dde310339vboxsync#!/bin/bash
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync# $Id$
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync## @file
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync# pure_test.sh - test the effect of __attribute__((pure)) on a set of
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync# functions.
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync#
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync# Mark the functions with EXPERIMENT_PURE where the attribute normally would,
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync# go update this script so it points to the right header and execute it. At
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync# the end you'll get a pt-report.txt showing the fluctuations in the text size.
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync#
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync#
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync# Copyright (C) 2010 Oracle Corporation
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync#
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync# available from http://www.virtualbox.org. This file is free software;
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync# you can redistribute it and/or modify it under the terms of the GNU
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync# General Public License (GPL) as published by the Free Software
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync# Foundation, in version 2 as it comes in the "COPYING" file of the
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync#
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync
3b018dd88828ff4d87147b8f84cb273dde310339vboxsyncset -e
3b018dd88828ff4d87147b8f84cb273dde310339vboxsyncset -x
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync
3b018dd88828ff4d87147b8f84cb273dde310339vboxsyncBINDIR="../../../out/linux.amd64/release/bin/"
3b018dd88828ff4d87147b8f84cb273dde310339vboxsyncDLLEXT="so"
3b018dd88828ff4d87147b8f84cb273dde310339vboxsyncHEADER="../../../include/VBox/cpum.h"
3b018dd88828ff4d87147b8f84cb273dde310339vboxsyncREPORT="pt-report.txt"
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync
3b018dd88828ff4d87147b8f84cb273dde310339vboxsynctest -e ${HEADER}.bak || kmk_cp $HEADER ${HEADER}.bak
3b018dd88828ff4d87147b8f84cb273dde310339vboxsyncNAMES=`kmk_sed -e '/EXPERIMENT_PURE/!d' -e '/^#/d' -e 's/^[^()]*([^()]*)[[:space:]]*\([^() ]*\)(.*$/\1/' ${HEADER}.bak `
3b018dd88828ff4d87147b8f84cb273dde310339vboxsyncecho NAMES=$NAMES
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync#
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync# baseline
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync#
3b018dd88828ff4d87147b8f84cb273dde310339vboxsynckmk_sed -e 's/EXPERIMENT_PURE//' ${HEADER}.bak --output ${HEADER}
3b018dd88828ff4d87147b8f84cb273dde310339vboxsynckmk KBUILD_TYPE=release VBoxVMM VMMR0 VMMGC
3b018dd88828ff4d87147b8f84cb273dde310339vboxsyncsize ${BINDIR}/VMMR0.r0 ${BINDIR}/VMMGC.gc ${BINDIR}/VBoxVMM.${DLLEXT} > pt-baseline.txt
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync
3b018dd88828ff4d87147b8f84cb273dde310339vboxsyncexec < "pt-baseline.txt"
3b018dd88828ff4d87147b8f84cb273dde310339vboxsyncread buf # ignore
3b018dd88828ff4d87147b8f84cb273dde310339vboxsyncread buf; baseline_r0=`echo $buf | kmk_sed -e 's/^[[:space:]]*\([^[[:space:]]*\).*$/\1/' `
3b018dd88828ff4d87147b8f84cb273dde310339vboxsyncread buf; baseline_rc=`echo $buf | kmk_sed -e 's/^[[:space:]]*\([^[[:space:]]*\).*$/\1/' `
3b018dd88828ff4d87147b8f84cb273dde310339vboxsyncread buf; baseline_r3=`echo $buf | kmk_sed -e 's/^[[:space:]]*\([^[[:space:]]*\).*$/\1/' `
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync
3b018dd88828ff4d87147b8f84cb273dde310339vboxsynckmk_cp -f "pt-baseline.txt" "${REPORT}"
3b018dd88828ff4d87147b8f84cb273dde310339vboxsynckmk_printf -- "\n" >> "${REPORT}"
3b018dd88828ff4d87147b8f84cb273dde310339vboxsynckmk_printf -- "%7s %7s %7s Name\n" "VMMR0" "VMMGC" "VBoxVMM" >> "${REPORT}"
3b018dd88828ff4d87147b8f84cb273dde310339vboxsynckmk_printf -- "-------------------------------\n" >> "${REPORT}"
3b018dd88828ff4d87147b8f84cb273dde310339vboxsynckmk_printf -- "%7d %7d %7d baseline\n" ${baseline_r0} ${baseline_rc} ${baseline_r3} >> "${REPORT}"
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync#
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync# Now, do each of the names.
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync#
3b018dd88828ff4d87147b8f84cb273dde310339vboxsyncfor name in $NAMES;
3b018dd88828ff4d87147b8f84cb273dde310339vboxsyncdo
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync kmk_sed \
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync -e '/'"${name}"'/s/EXPERIMENT_PURE/__attribute__((pure))/' \
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync -e 's/EXPERIMENT_PURE//' \
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync ${HEADER}.bak --output ${HEADER}
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync kmk KBUILD_TYPE=release VBoxVMM VMMR0 VMMGC
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync size ${BINDIR}/VMMR0.r0 ${BINDIR}/VMMGC.gc ${BINDIR}/VBoxVMM.${DLLEXT} > "pt-${name}.txt"
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync exec < "pt-${name}.txt"
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync read buf # ignore
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync read buf; cur_r0=`echo $buf | kmk_sed -e 's/^[[:space:]]*\([^[[:space:]]*\).*$/\1/' `
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync read buf; cur_rc=`echo $buf | kmk_sed -e 's/^[[:space:]]*\([^[[:space:]]*\).*$/\1/' `
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync read buf; cur_r3=`echo $buf | kmk_sed -e 's/^[[:space:]]*\([^[[:space:]]*\).*$/\1/' `
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync kmk_printf -- "%7d %7d %7d ${name}\n" \
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync `kmk_expr ${baseline_r0} - ${cur_r0} ` \
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync `kmk_expr ${baseline_rc} - ${cur_rc} ` \
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync `kmk_expr ${baseline_r3} - ${cur_r3} ` \
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync >> "${REPORT}"
3b018dd88828ff4d87147b8f84cb273dde310339vboxsyncdone
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync# clean up
3b018dd88828ff4d87147b8f84cb273dde310339vboxsynckmk_mv -f ${HEADER}.bak ${HEADER}
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync
3b018dd88828ff4d87147b8f84cb273dde310339vboxsync