diff --git a/scripts/count_violations.sh b/scripts/count_violations.sh new file mode 100644 index 0000000..f182b75 --- /dev/null +++ b/scripts/count_violations.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +#--------------------------------------------------------------------- +# +# Copyright (C) 2015- by Tiziano De Matteis (dematteis di.unipi.it) +# +# This file is part of elastic-hft. +# +# elastic-hft is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# --------------------------------------------------------------------- +# Count the number of violations taking in input a directory containing the stats files +# e.g. generated with conf_interval_real or conf_interval_synthetic scripts + +if [ -z "$1" ]; then + echo "Specify the directory containing the stat files as first command line argument" + exit 1 +fi + +if [ -z "$2" ]; then + echo "Specify the latency threshold (in usecs) as second command line argument" + exit 1 +fi + +if [ ! -d "$1" ]; then + echo "The directory $1 does not exists!" + exit 1 +fi + + +for stat_file in $1/stat*dat +do + tail -n +2 $stat_file | head -n -2 | cut -f 3 | awk -v thr=$2 'BEGIN {count=0} {if($1>thr){count++}} END{print count;}' >> tmp_violations +done + + +cat tmp_violations | awk 'BEGIN{sum=0; count=0;} {sum+=$1; count++;} END {print "Average #violations: "sum/count;}' +rm tmp_violations; diff --git a/src/utils.cpp b/src/utils.cpp index 1337ee2..36d300b 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -99,14 +99,19 @@ std::vector* getCoreIDs() num_virt_cores+= cpu->getVirtualCores().size(); } std::vector *core_ids=new std::vector(); - - std::vector virtualCores = topology->getVirtualCores(); + std::vector physicalCores= topology->getPhysicalCores(); //now take the id of one virtual core per physical core; //assuming that physical core are number starting from zero - int curr_phys_core=0; bool constantTSC=true; - for(size_t i = 0; i < virtualCores.size(); i++) + for(size_t i=0;ipush_back(pc->getVirtualCore()->getVirtualCoreId()); + if(!pc->getVirtualCore()->areTicksConstant()) + constantTSC=false; + } + /* for(size_t i = 0; i < virtualCores.size(); i++) { VirtualCore* vc = virtualCores.at(i); if(vc->getPhysicalCoreId()==curr_phys_core) @@ -116,7 +121,7 @@ std::vector* getCoreIDs() } if(!vc->areTicksConstant()) constantTSC=false; - } + }*/ if(!constantTSC) std::cout<< "ATTENTION: the machine has not constant TSC. The program may not work since relies on this to get accurate timings" <