コード例 #1
0
ファイル: experiment.py プロジェクト: lucadt/memoizeit
 def _filter_tuples(self, depth):
    white_list = '%s/%s' % (self.folder, config.white_list_file())      
    tuples_output = '%s/%s/%s' % (self.folder, config.tuples_dir(), config.tuples_output_file())
    depths_csv = '%s/%s/%s' % (self.folder, config.tuples_dir(), config.tuples_depths_file())
    tuples_final = '%s/%s' % (self.folder, config.tuples_final_file())
    hit_rates = '%s/hit_rates_%d.txt' % (self.folder, depth) 
    min_hit_rate = 0.5
    running = 'java -cp %s cpb.RefineCandidateMethods %d %f %s %s %s %s %s' % (commons.scala_libs(), depth, min_hit_rate, tuples_output, depths_csv, tuples_final, hit_rates, white_list)
    self._create_filter_depths_trace()            
    subprocess.call(shlex.split(str(running)))
コード例 #2
0
 def _create_filter_depths_trace(self):
     depths_csv = '%s/%s/%s' % (self.folder, config.tuples_dir(),
                                config.tuples_depths_file())
     methods_file = '%s/%s/%s' % (self.folder, config.tuples_dir(),
                                  'methods.txt')
     trace_file = '%s/%s/data/thread_1_main/log_depth.txt' % (
         self.folder, config.tuples_dir())
     running = 'java -jar %s %s --trace %s --methods %s --output %s' % (
         commons.jython_jar(), commons.depths_script_py(), trace_file,
         methods_file, depths_csv)
     subprocess.call(shlex.split(str(running)))
コード例 #3
0
 def _filter_tuples(self, depth):
     white_list = '%s/%s' % (self.folder, config.white_list_file())
     tuples_output = '%s/%s/%s' % (self.folder, config.tuples_dir(),
                                   config.tuples_output_file())
     depths_csv = '%s/%s/%s' % (self.folder, config.tuples_dir(),
                                config.tuples_depths_file())
     tuples_final = '%s/%s' % (self.folder, config.tuples_final_file())
     hit_rates = '%s/hit_rates_%d.txt' % (self.folder, depth)
     min_hit_rate = 0.5
     running = 'java -cp %s cpb.RefineCandidateMethods %d %f %s %s %s %s %s' % (
         commons.scala_libs(), depth, min_hit_rate, tuples_output,
         depths_csv, tuples_final, hit_rates, white_list)
     self._create_filter_depths_trace()
     subprocess.call(shlex.split(str(running)))
コード例 #4
0
 def _max_depth_reached(self):
     if commons.profile_exaustive() == True:
         return True
     else:
         return not os.path.isfile('%s/%s/%s' %
                                   (self.folder, config.tuples_dir(),
                                    config.tuples_max_depth_file()))
コード例 #5
0
    def refine_candidates(self):
        #
        self._filter_with_black_list()
        #
        depth = 1
        #
        use_max_depth = not commons.profile_exaustive()
        #
        get_next_depth = None
        if commons.increment_function() == 'inc1':
            get_next_depth = lambda x: x + 1
        elif commons.increment_function() == 'pow2':
            get_next_depth = lambda x: 2 * x
        else:
            if commons.profile_exaustive() == False:
                raise Exeception(
                    'Increment function parameter has wrong value -- ' +
                    commons.increment_function())
            get_next_depth = None

        while (True):
            commons.log('Exploring depth ' + str(depth) + ' -- ' + '"' +
                        self.program.prefix + '"')
            self._save_white_list(depth)
            tuple_options = options.TuplesOptions(use_max_depth, depth, True,
                                                  False)
            self.program.tuples(tuple_options)
            self._write_options_to_file(
                '%s/%s' % (self.folder, config.tuples_dir()), tuple_options)
            stop = False
            if self._max_depth_reached():
                stop = True
            #
            if commons.profile_exaustive() == False:
                self._filter_tuples(depth)
                self._save_current_depth_directory(depth)
            #
            candidates_list_new = '%s/%s' % (self.folder,
                                             config.white_list_file())
            number_of_candidates = self._count_lines(candidates_list_new)
            #
            if number_of_candidates == 0:
                commons.log('No caching candidates left to explore' + ' -- ' +
                            str(depth) + ' -- ' + '"' + self.program.prefix +
                            '"')
                break
            #
            if stop:
                self._create_tuples_file()
                commons.log('Max depth ' + str(depth) + 'reached' + ' -- ' +
                            '"' + self.program.prefix + '"')
                break
            depth = get_next_depth(depth)
コード例 #6
0
ファイル: experiment.py プロジェクト: lucadt/memoizeit
 def refine_candidates(self):
    #
    self._filter_with_black_list()
    #
    depth = 1
    #
    use_max_depth = not commons.profile_exaustive()
    #
    get_next_depth = None
    if commons.increment_function() == 'inc1':
       get_next_depth = lambda x: x + 1
    elif commons.increment_function() == 'pow2':
       get_next_depth = lambda x: 2 * x
    else:
       if commons.profile_exaustive() == False:
          raise Exeception('Increment function parameter has wrong value -- ' + commons.increment_function())
       get_next_depth = None
       
    while (True):
       commons.log('Exploring depth ' + str(depth) + ' -- ' + '"' + self.program.prefix + '"')
       self._save_white_list(depth)
       tuple_options = options.TuplesOptions(use_max_depth, depth, True, False)
       self.program.tuples(tuple_options)
       self._write_options_to_file('%s/%s' % (self.folder, config.tuples_dir()), tuple_options)
       stop = False
       if self._max_depth_reached():
          stop = True
       #
       if commons.profile_exaustive() == False:
          self._filter_tuples(depth)
          self._save_current_depth_directory(depth)
       #
       candidates_list_new = '%s/%s' % (self.folder, config.white_list_file())      
       number_of_candidates = self._count_lines(candidates_list_new)
       #
       if number_of_candidates == 0:
          commons.log('No caching candidates left to explore' + ' -- ' + str(depth) + ' -- ' + '"' + self.program.prefix + '"')
          break 
       #
       if stop:
          self._create_tuples_file()
          commons.log('Max depth ' +  str(depth) + 'reached' + ' -- ' + '"' + self.program.prefix + '"')
          break
       depth = get_next_depth(depth)
コード例 #7
0
 def _create_tuples_file(self):
     if commons.profile_exaustive() == True:
         from_file = '%s/%s/%s' % (self.folder, config.tuples_dir(),
                                   config.tuples_output_file())
         to_file = '%s/%s' % (self.folder, config.tuples_final_file())
         self._copy_file(from_file, to_file)
コード例 #8
0
 def _save_current_depth_directory(self, depth):
     self._move_file('%s/%s' % (self.folder, config.tuples_dir()),
                     '%s/%d' % (self.folder, depth))
     self._move_file(
         '%s/%d.txt' % (self.folder, depth),
         '%s/%d/%s' % (self.folder, depth, config.white_list_file()))
コード例 #9
0
ファイル: experiment.py プロジェクト: lucadt/memoizeit
 def _create_filter_depths_trace(self):
    depths_csv = '%s/%s/%s' % (self.folder, config.tuples_dir(), config.tuples_depths_file())
    methods_file = '%s/%s/%s' % (self.folder, config.tuples_dir(), 'methods.txt')
    trace_file = '%s/%s/data/thread_1_main/log_depth.txt' % (self.folder, config.tuples_dir())
    running = 'java -jar %s %s --trace %s --methods %s --output %s' % (commons.jython_jar(), commons.depths_script_py(), trace_file, methods_file, depths_csv)         
    subprocess.call( shlex.split( str(running)) )
コード例 #10
0
ファイル: experiment.py プロジェクト: lucadt/memoizeit
 def _max_depth_reached(self):
    if commons.profile_exaustive() == True:
       return True
    else:
       return not os.path.isfile('%s/%s/%s' % (self.folder, config.tuples_dir(), config.tuples_max_depth_file()))
コード例 #11
0
ファイル: experiment.py プロジェクト: lucadt/memoizeit
 def _create_tuples_file(self):
    if commons.profile_exaustive() == True:
       from_file = '%s/%s/%s' % (self.folder, config.tuples_dir(), config.tuples_output_file())
       to_file = '%s/%s' % (self.folder, config.tuples_final_file())                
       self._copy_file(from_file, to_file)
コード例 #12
0
ファイル: experiment.py プロジェクト: lucadt/memoizeit
 def _save_current_depth_directory(self, depth):
    self._move_file('%s/%s' % (self.folder, config.tuples_dir()), '%s/%d' % (self.folder, depth))
    self._move_file('%s/%d.txt' % (self.folder, depth) , '%s/%d/%s' % (self.folder, depth, config.white_list_file()))