Last active
August 29, 2015 14:03
-
-
Save pitrou/0d2c082fad365d401b7b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gc | |
import sys | |
import llvm.core as lc | |
import llvm.ee as le | |
# Cache plausible return values for sys.getallocatedblocks() - _base, to avoid | |
# allocating them later. | |
_int_pool = {} | |
for i in range(-2048, 2048): | |
_int_pool[i] = i | |
del i | |
NITERS = 100 | |
alloc = [0] * NITERS | |
gc.collect() | |
_base = sys.getallocatedblocks() | |
for i in range(NITERS): | |
mod = lc.Module.new("foobar") | |
if 1: | |
eb = le.EngineBuilder.new(mod) | |
eb.opt(3) | |
eb = mod = None | |
gc.collect() | |
alloc[i] = _int_pool[sys.getallocatedblocks() - _base] | |
print("alloc =", alloc) | |
print("deltas =", [b - a for (a, b) in zip(alloc, alloc[1:])]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment