本文整理汇总了Python中pypy.rlib.debug.debug_print函数的典型用法代码示例。如果您正苦于以下问题:Python debug_print函数的具体用法?Python debug_print怎么用?Python debug_print使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了debug_print函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_total_memory_linux2
def get_total_memory_linux2(filename):
debug_start("gc-hardware")
result = -1.0
try:
fd = os.open(filename, os.O_RDONLY, 0644)
try:
buf = os.read(fd, 4096)
finally:
os.close(fd)
except OSError:
pass
else:
if buf.startswith('MemTotal:'):
start = _skipspace(buf, len('MemTotal:'))
stop = start
while stop < len(buf) and buf[stop].isdigit():
stop += 1
if start < stop:
result = float(buf[start:stop]) * 1024.0 # assume kB
if result < 0.0:
debug_print("get_total_memory() failed")
result = addressable_size
else:
debug_print("memtotal =", result)
if result > addressable_size:
result = addressable_size
debug_stop("gc-hardware")
return result
示例2: _print_stats
def _print_stats(self):
cnt = self.counters
tim = self.times
calls = self.calls
self._print_line_time("Tracing", cnt[TRACING], tim[TRACING])
self._print_line_time("Backend", cnt[BACKEND], tim[BACKEND])
line = "TOTAL: \t\t%f" % (self.tk - self.starttime, )
debug_print(line)
self._print_intline("ops", cnt[OPS])
self._print_intline("recorded ops", cnt[RECORDED_OPS])
self._print_intline(" calls", calls)
self._print_intline("guards", cnt[GUARDS])
self._print_intline("opt ops", cnt[OPT_OPS])
self._print_intline("opt guards", cnt[OPT_GUARDS])
self._print_intline("forcings", cnt[OPT_FORCINGS])
self._print_intline("abort: trace too long", cnt[ABORT_TOO_LONG])
self._print_intline("abort: compiling", cnt[ABORT_BRIDGE])
self._print_intline("abort: vable escape", cnt[ABORT_ESCAPE])
self._print_intline("abort: bad loop", cnt[ABORT_BAD_LOOP])
self._print_intline("abort: force quasi-immut",
cnt[ABORT_FORCE_QUASIIMMUT])
self._print_intline("nvirtuals", cnt[NVIRTUALS])
self._print_intline("nvholes", cnt[NVHOLES])
self._print_intline("nvreused", cnt[NVREUSED])
cpu = self.cpu
if cpu is not None: # for some tests
self._print_intline("Total # of loops",
cpu.total_compiled_loops)
self._print_intline("Total # of bridges",
cpu.total_compiled_bridges)
self._print_intline("Freed # of loops",
cpu.total_freed_loops)
self._print_intline("Freed # of bridges",
cpu.total_freed_bridges)
示例3: f
def f():
state.data = []
state.datalen1 = 0
state.datalen2 = 0
state.datalen3 = 0
state.datalen4 = 0
state.threadlocals = gil.GILThreadLocals()
state.threadlocals.setup_threads(space)
thread.gc_thread_prepare()
subident = thread.start_new_thread(bootstrap, ())
mainident = thread.get_ident()
runme(True)
still_waiting = 3000
while len(state.data) < 2*N:
debug_print(len(state.data))
if not still_waiting:
raise ValueError("time out")
still_waiting -= 1
if not we_are_translated(): gil.before_external_call()
time.sleep(0.01)
if not we_are_translated(): gil.after_external_call()
debug_print("leaving!")
i1 = i2 = 0
for tid, i in state.data:
if tid == mainident:
assert i == i1; i1 += 1
elif tid == subident:
assert i == i2; i2 += 1
else:
assert 0
assert i1 == N + skew
assert i2 == N - skew
return len(state.data)
示例4: update
def update(self, op):
if (op.has_no_side_effect() or
op.is_ovf() or
op.is_guard()):
return
opnum = op.getopnum()
descr = op.getdescr()
if (opnum == rop.DEBUG_MERGE_POINT):
return
if (opnum == rop.SETFIELD_GC or
opnum == rop.SETFIELD_RAW):
self.unsafe_getitem[descr] = True
return
if (opnum == rop.SETARRAYITEM_GC or
opnum == rop.SETARRAYITEM_RAW):
index = op.getarg(1)
if isinstance(index, Const):
d = self.unsafe_getarrayitem_indexes.get(descr, None)
if d is None:
d = self.unsafe_getarrayitem_indexes[descr] = {}
d[index.getint()] = True
else:
self.unsafe_getarrayitem[descr] = True
return
if opnum == rop.CALL:
effectinfo = descr.get_extra_info()
if effectinfo is not None:
for fielddescr in effectinfo.write_descrs_fields:
self.unsafe_getitem[fielddescr] = True
for arraydescr in effectinfo.write_descrs_arrays:
self.unsafe_getarrayitem[arraydescr] = True
return
debug_print("heap dirty due to op ", opnum)
self.heap_dirty = True
示例5: f
def f(x):
debug_start("mycat")
debug_print("foo", 2, "bar", x)
debug_stop("mycat")
debug_flush() # does nothing
debug_offset() # should not explode at least
return have_debug_prints()
示例6: debug_print
def debug_print(self, hdr='', bad=None):
if bad is None:
bad = {}
debug_print(hdr + "VirtualState():")
seen = {}
for s in self.state:
s.debug_print(" ", seen, bad)
示例7: debug_collect_finish
def debug_collect_finish(self):
if 1:# start_time != -1:
#end_time = time.time()
#elapsed_time = end_time - start_time
#self.total_collection_time += elapsed_time
#self.total_collection_count += 1
#total_program_time = end_time - self.program_start_time
#ct = self.total_collection_time
#cc = self.total_collection_count
#debug_print("| number of collections so far ",
# cc)
debug_print("| total space size ",
self.space_size)
debug_print("| number of objects alive ",
self.num_alive_objs)
debug_print("| used space size ",
self.free - self.space)
debug_print("| next collection after ",
self.next_collect_after)
#debug_print("| total collections per second: ",
# cc / total_program_time)
#debug_print("| total time in markcompact-collect: ",
# ct, "seconds")
#debug_print("| percentage collection<->total time:",
# ct * 100.0 / total_program_time, "%")
debug_print("`----------------------------------------------")
debug_stop("gc-collect")
示例8: get_L2cache_linux2
def get_L2cache_linux2(filename="/proc/cpuinfo"):
debug_start("gc-hardware")
L2cache = sys.maxint
try:
fd = os.open(filename, os.O_RDONLY, 0644)
try:
data = []
while True:
buf = os.read(fd, 4096)
if not buf:
break
data.append(buf)
finally:
os.close(fd)
except OSError:
pass
else:
data = ''.join(data)
linepos = 0
while True:
start = _findend(data, '\ncache size', linepos)
if start < 0:
break # done
linepos = _findend(data, '\n', start)
if linepos < 0:
break # no end-of-line??
# *** data[start:linepos] == " : 2048 KB\n"
start = _skipspace(data, start)
if data[start] != ':':
continue
# *** data[start:linepos] == ": 2048 KB\n"
start = _skipspace(data, start + 1)
# *** data[start:linepos] == "2048 KB\n"
end = start
while '0' <= data[end] <= '9':
end += 1
# *** data[start:end] == "2048"
if start == end:
continue
number = int(data[start:end])
# *** data[end:linepos] == " KB\n"
end = _skipspace(data, end)
if data[end] not in ('K', 'k'): # assume kilobytes for now
continue
number = number * 1024
# for now we look for the smallest of the L2 caches of the CPUs
if number < L2cache:
L2cache = number
debug_print("L2cache =", L2cache)
debug_stop("gc-hardware")
if L2cache < sys.maxint:
return L2cache
else:
# Print a top-level warning even in non-debug builds
llop.debug_print(lltype.Void,
"Warning: cannot find your CPU L2 cache size in /proc/cpuinfo")
return -1
示例9: _emergency_initial_block
def _emergency_initial_block(self, requested_size):
# xxx before the GC is fully setup, we might get there. Hopefully
# we will only allocate a couple of strings, e.g. in read_from_env().
# Just allocate them raw and leak them.
debug_start("gc-initial-block")
debug_print("leaking", requested_size, "bytes")
debug_stop("gc-initial-block")
return llmemory.raw_malloc(requested_size)
示例10: _check_rawsize_alloced
def _check_rawsize_alloced(self, size_estimate, can_collect=True):
self.large_objects_collect_trigger -= size_estimate
if can_collect and self.large_objects_collect_trigger < 0:
debug_start("gc-rawsize-collect")
debug_print("allocated", (self._initial_trigger -
self.large_objects_collect_trigger),
"bytes, triggering full collection")
self.semispace_collect()
debug_stop("gc-rawsize-collect")
示例11: disable_noninlinable_function
def disable_noninlinable_function(self, metainterp):
greenkey = metainterp.greenkey_of_huge_function
if greenkey is not None:
cell = self.jit_cell_at_key(greenkey)
cell.dont_trace_here = True
debug_start("jit-disableinlining")
sd = self.warmrunnerdesc.metainterp_sd
loc = sd.state.get_location_str(greenkey)
debug_print("disabled inlining", loc)
debug_stop("jit-disableinlining")
示例12: crash_in_jit
def crash_in_jit(e):
if not we_are_translated():
print "~~~ Crash in JIT!"
print '~~~ %s: %s' % (e.__class__, e)
if sys.stdout == sys.__stdout__:
import pdb; pdb.post_mortem(sys.exc_info()[2])
raise
debug_print('~~~ Crash in JIT!')
debug_print('~~~ %s' % (e,))
raise history.CrashInJIT("crash in JIT")
示例13: propagate_forward
def propagate_forward(self, op):
if self.logops is not None:
debug_print(self.logops.repr_of_resop(op))
opnum = op.getopnum()
for value, func in optimize_ops:
if opnum == value:
func(self, op)
break
else:
self.emit_operation(op)
示例14: _end
def _end(self, event):
t0 = self.t1
self.t1 = self.timer()
if not self.current:
debug_print("BROKEN PROFILER DATA!")
return
ev1 = self.current.pop()
if ev1 != event:
debug_print("BROKEN PROFILER DATA!")
return
self.times[ev1] += self.t1 - t0
示例15: get_total_memory_darwin
def get_total_memory_darwin(result):
debug_start("gc-hardware")
if result <= 0:
debug_print("get_total_memory() failed")
result = addressable_size
else:
debug_print("memtotal = ", result)
if result > addressable_size:
result = addressable_size
debug_stop("gc-hardware")
return result