Skip to content

Instantly share code, notes, and snippets.

@cfbolz
Created July 7, 2014 15:07
Show Gist options
  • Save cfbolz/7799bba1031ef2e3f13d to your computer and use it in GitHub Desktop.
Save cfbolz/7799bba1031ef2e3f13d to your computer and use it in GitHub Desktop.
diff type profiling cells pycket
diff --git a/pycket/values.py b/pycket/values.py
index ef11567..a2ca9de 100755
--- a/pycket/values.py
+++ b/pycket/values.py
@@ -42,12 +42,24 @@ class W_Object(object):
def eqv(self, other):
return self is other # default implementation
+from collections import defaultdict
+celltypes = defaultdict(int)
+settypes = defaultdict(int)
+
+import atexit
+def printall():
+ print "at construction", celltypes
+ print "when set", settypes
+atexit.register(printall)
+
class W_Cell(W_Object): # not the same as Racket's box
def __init__(self, v):
+ celltypes[type(v)] += 1
assert not isinstance(v, W_Cell)
self.value = v
def set_val(self, w_value):
+ settypes[type(w_value)] += 1
self.value = w_value
class W_MVector(W_Object):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment