コード例 #1
0
ファイル: warmspot.py プロジェクト: enyst/plexnet
 def add_profiler_finish(self):
     def finish_profiler():
         if self.metainterp_sd.profiler.initialized:
             self.metainterp_sd.profiler.finish()
     
     if self.cpu.translate_support_code:
         call_final_function(self.translator, finish_profiler,
                             annhelper = self.annhelper)
コード例 #2
0
 def add_finish(self):
     def finish():
         if self.metainterp_sd.profiler.initialized:
             self.metainterp_sd.profiler.finish()
         self.metainterp_sd.cpu.finish_once()
     
     if self.cpu.translate_support_code:
         call_final_function(self.translator, finish,
                             annhelper = self.annhelper)
コード例 #3
0
ファイル: test_unsimplify.py プロジェクト: Debug-Orz/Sypy
def test_call_final_function():
    tmpfile = str(udir.join('test_call_final_function'))
    for type_system in ['lltype', 'ootype']:
        def f(x):
            return x * 6
        def goodbye_world():
            if we_are_translated():
                fd = os.open(tmpfile, os.O_WRONLY | os.O_CREAT, 0644)
                os.close(fd)
        graph, t = translate(f, [int], type_system)
        call_final_function(t, goodbye_world)
        #
        if os.path.exists(tmpfile):
            os.unlink(tmpfile)
        interp = LLInterpreter(t.rtyper)
        result = interp.eval_graph(graph, [7])
        assert result == 42
        assert os.path.isfile(tmpfile)
コード例 #4
0
def test_call_final_function():
    tmpfile = str(udir.join('test_call_final_function'))
    for type_system in ['lltype', 'ootype']:
        def f(x):
            return x * 6
        def goodbye_world():
            if we_are_translated():
                fd = os.open(tmpfile, os.O_WRONLY | os.O_CREAT, 0)
                os.close(fd)
        graph, t = translate(f, [int], type_system)
        call_final_function(t, goodbye_world)
        #
        if os.path.exists(tmpfile):
            os.unlink(tmpfile)
        interp = LLInterpreter(t.rtyper)
        result = interp.eval_graph(graph, [7])
        assert result == 42
        assert os.path.isfile(tmpfile)