From 15959a34546d3b712edec087ce0ffe493ac1f0ab Mon Sep 17 00:00:00 2001 From: Hamed Gorjiara Date: Thu, 27 Jun 2019 13:07:46 -0700 Subject: [PATCH] Infering the number of runs --- src/Test/analyzemultituner.cc | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/Test/analyzemultituner.cc b/src/Test/analyzemultituner.cc index effe965..f132e74 100644 --- a/src/Test/analyzemultituner.cc +++ b/src/Test/analyzemultituner.cc @@ -1,15 +1,30 @@ #include "csolver.h" #include "comptuner.h" #include "searchtuner.h" +#include "dirent.h" -int main(int argc, char **argv) { - if (argc < 2) { - printf("You should specify number of runs\n"); - exit(-1); +uint getNumberOfRuns(){ + uint runs = 0; + DIR *dir; + struct dirent *ent; + if ((dir = opendir ("./")) != NULL) { + /* print all the files and directories within directory */ + while ((ent = readdir (dir)) != NULL) { + if(strstr(ent->d_name, "result") != NULL){ + runs++; + } + } + closedir (dir); + } else { + perror ("Unable to open the directory\n"); + exit(1); } - uint numruns; - sscanf(argv[1], "%u", &numruns); + return runs; +} +int main(int argc, char **argv) { + uint numruns = getNumberOfRuns(); + printf("Number of Runs: %u\n", numruns); CompTuner *multituner = new CompTuner(0, 0); multituner->readData(numruns); multituner->findBestThreeTuners(); -- 2.34.1