提交 cd8bc0b0 authored 作者: Frederic Bastien's avatar Frederic Bastien

ProfileMode now profile the compilation time too.

上级 4fd78082
......@@ -12,6 +12,7 @@ import numpy
from .. import gof
import sys
import copy
import time
import mode as mode_module
from io import *
......@@ -788,6 +789,7 @@ def function(inputs, outputs, mode=None, accept_inplace = False):
f[<kitname>] = seed #re-seed the elements of a RandomKit
"""
t1 = time.time()
mode = mode if mode is not None else mode_module.default_mode
......@@ -819,6 +821,9 @@ def function(inputs, outputs, mode=None, accept_inplace = False):
Maker = getattr(mode, 'function_maker', FunctionMaker)
fn = Maker(inputs, outputs, mode, accept_inplace = accept_inplace).create(defaults)
t2 = time.time()
if hasattr(mode, 'compile_time'):
mode.compile_time+=t2-t1
return fn
......
......@@ -31,6 +31,7 @@ class ProfileMode(Mode):
self.apply_time = apply_time
self.op_time = op_time
self.op_cimpl = op_cimpl
self.compile_time = 0 #time passed in function()
if isinstance(linker, str):
linker = predefined_linkers[linker]
......@@ -110,7 +111,7 @@ class ProfileMode(Mode):
sum(f for f, t, a in sotimes[n_ops_to_print:])*100,
sum(t for f, t, a in sotimes[n_ops_to_print:]))
print '(*) Op is running a c implementation'
print 'compile time: %.3fs'%self.compile_time
register_mode('PROFILE_MODE',ProfileMode())
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论