Example #1
0
 def setup(self):
     heat_time = self.misc_settings["time"]
     logging.info("Preheat the system for {} seconds with a cpu bound task"
                  .format(heat_time))
     cmd = "timeout {} python3 -c 'import numpy as np; " \
           "m = np.random.randint(0, 100, (500, 500)); " \
           "print(list(map(lambda x: len(np.linalg.eig(m)), range(10000))))' > /dev/null".format(heat_time)
     if does_command_succeed("python3 -c 'import numpy as np; '") and does_program_exist("bash"):
         # source: http://bruxy.regnet.cz/web/linux/EN/mandelbrot-set-in-bash/
         cmd = """bash -c "
         #!/bin/bash
         S0=S;S1=H;S2=E;S3=L;S4=L;e=echo;b=bc;I=-1;for x in {1..24};
         do R=-2;for y in {1..80};do B=0;r=0;i=0;while [ $B -le 32 ];do
         r2=`$e "$r*$r"|$b`;i2=`$e "$i*$i"|$b`;i=`$e "2*$i*$r+$I"|$b`;
         r=`$e "$r2-$i2+$R"|$b`;: $((B+=1));V=`$e "($r2 +$i2)>4"|$b`;
         if [ "$V" -eq 1 ];then break;fi;done; if [ $B -ge 32 ];then
         $e -n " ";else U=$(((B*4)/15+30));$e -en "\E[01;$U""m";C=$((C%5));
         eval "$e -ne \$E\$S$C";: $((C+=1));fi;R=`$e "$R+0.03125"|$b`
         done;$e -e "\E[m\E(\r";I=`$e "$I+0.08333"|$b`;done      #(c)BruXy "
         """
     procs = []
     for i in range(0, multiprocessing.cpu_count()):
         proc = subprocess.Popen(["/bin/sh", "-c", cmd], stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE,
                                 universal_newlines=True)
         procs.append(proc)
     time.sleep(heat_time)
     for proc in procs:
         try:
             proc.poll()
         except BaseException as ex:
             logging.error(ex)
Example #2
0
 def setup(self):
     heat_time = self.misc_settings["time"]
     logging.info(
         "Preheat the system for {} seconds with a cpu bound task".format(
             heat_time))
     cmd = "timeout {} python3 -c 'import numpy as np; " \
           "m = np.random.randint(0, 100, (500, 500)); " \
           "print(list(map(lambda x: len(np.linalg.eig(m)), range(10000))))' > /dev/null".format(heat_time)
     if does_command_succeed("python3 -c 'import numpy as np; '"
                             ) and does_program_exist("bash"):
         # source: http://bruxy.regnet.cz/web/linux/EN/mandelbrot-set-in-bash/
         cmd = """bash -c "
         #!/bin/bash
         S0=S;S1=H;S2=E;S3=L;S4=L;e=echo;b=bc;I=-1;for x in {1..24};
         do R=-2;for y in {1..80};do B=0;r=0;i=0;while [ $B -le 32 ];do
         r2=`$e "$r*$r"|$b`;i2=`$e "$i*$i"|$b`;i=`$e "2*$i*$r+$I"|$b`;
         r=`$e "$r2-$i2+$R"|$b`;: $((B+=1));V=`$e "($r2 +$i2)>4"|$b`;
         if [ "$V" -eq 1 ];then break;fi;done; if [ $B -ge 32 ];then
         $e -n " ";else U=$(((B*4)/15+30));$e -en "\E[01;$U""m";C=$((C%5));
         eval "$e -ne \$E\$S$C";: $((C+=1));fi;R=`$e "$R+0.03125"|$b`
         done;$e -e "\E[m\E(\r";I=`$e "$I+0.08333"|$b`;done      #(c)BruXy "
         """
     procs = []
     for i in range(0, multiprocessing.cpu_count()):
         proc = subprocess.Popen(["/bin/sh", "-c", cmd],
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE,
                                 universal_newlines=True)
         procs.append(proc)
     time.sleep(heat_time)
     for proc in procs:
         try:
             proc.poll()
         except BaseException as ex:
             logging.error(ex)
Example #3
0
 def __init__(self, block: RunProgramBlock):
     super().__init__(block)
     if not does_command_succeed(
             setup.script_relative("rusage/rusage") + " true"):
         raise KeyboardInterrupt(
             "The needed c code for rusage seems to be not compiled properly. "
             "Please run temci setup.")
Example #4
0
 def __init__(self, block: RunProgramBlock):
     super().__init__(block)
     if not does_command_succeed(time_file() + " -v true"):
         raise KeyboardInterrupt(
             "gnu time seems to be not installed and the time runner can therefore not be used"
         )
     fmts = get_av_time_properties_with_format_specifiers()
     self._time_format_spec = "### " + " ".join(
         ["%" + fmts[prop][1] for prop in self.misc["properties"]])
Example #5
0
    def store(self, filename: str, compression_level: int = None):
        """
        Store the whole database as a compressed archive under the given file name.

        :param filename: passed file name
        :param compression_level: used compression level, from -1 (low) to -9 (high)
        """
        compression_level = compression_level or Settings()["package/compression/level"]
        self._store_yaml()
        filename = abspath(filename)
        used_prog = "gzip"
        av_programs = ["pixz", "xz"] if Settings()["package/compression/program"] == "xz" else ["pigz", "gzip"]
        for prog in av_programs:
            if does_command_succeed(prog + " --version"):
                used_prog = prog
                break
        cmd = "cd {dir}; XZ={l} GZIP={l} tar cf '{dest}' . --use-compress-program={prog}"\
            .format(l=compression_level, dest=filename, dir=self.tmp_dir, prog=used_prog)
        res = subprocess.check_output(["/bin/sh", "-c", cmd])
Example #6
0
    def store(self, filename: str, compression_level: int = None):
        """
        Store the whole database as a compressed archive under the given file name.

        :param filename: passed file name
        :param compression_level: used compression level, from -1 (low) to -9 (high)
        """
        compression_level = compression_level or Settings(
        )["package/compression/level"]
        self._store_yaml()
        filename = abspath(filename)
        used_prog = "gzip"
        av_programs = ["pixz", "xz"] if Settings(
        )["package/compression/program"] == "xz" else ["pigz", "gzip"]
        for prog in av_programs:
            if does_command_succeed(prog + " --version"):
                used_prog = prog
                break
        cmd = "cd {dir}; XZ={l} GZIP={l} tar cf '{dest}' . --use-compress-program={prog}"\
            .format(l=compression_level, dest=filename, dir=self.tmp_dir, prog=used_prog)
        res = subprocess.check_output(["/bin/sh", "-c", cmd])
Example #7
0
 def __init__(self, block: RunProgramBlock):
     super().__init__(block)
     if not does_command_succeed(setup.script_relative("rusage/rusage") + " true"):
         raise KeyboardInterrupt("The needed c code for rusage seems to be not compiled properly. "
                                 "Please run temci setup.")
Example #8
0
 def __init__(self, block: RunProgramBlock):
     super().__init__(block)
     if not does_command_succeed(time_file() + " -v true"):
         raise KeyboardInterrupt("gnu time seems to be not installed and the time runner can therefore not be used")
     fmts = get_av_time_properties_with_format_specifiers()
     self._time_format_spec = "### " + " ".join(["%" + fmts[prop][1] for prop in self.misc["properties"]])