Skip to content

Instantly share code, notes, and snippets.

@mathieu-lacage
Created July 28, 2021 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mathieu-lacage/c65e31404833af35947004dc431a4348 to your computer and use it in GitHub Desktop.
Save mathieu-lacage/c65e31404833af35947004dc431a4348 to your computer and use it in GitHub Desktop.
pypy memory test
import json
import time
import sys
import unicodedata
import re
import gc
CHARACTER_WHITESPACE = '\u2581'
class MyHooks(object):
done = False
def on_gc_minor(self, stats):
pass
def on_gc_collect_step(self, stats):
pass
def on_gc_collect(self, stats):
print(gc.get_stats(True))
hooks = MyHooks()
gc.hooks.set(hooks)
def read(filename):
with open(filename) as f:
for line in f:
yield json.loads(line)
def main():
time.sleep(2)
l = read(sys.argv[1])
l = [CHARACTER_WHITESPACE + re.sub('\s+', CHARACTER_WHITESPACE, i) for i in l]
time.sleep(5)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment