Skip to content

Instantly share code, notes, and snippets.

@schmichael
Created March 5, 2012 03:31
Show Gist options
  • Save schmichael/1976314 to your computer and use it in GitHub Desktop.
Save schmichael/1976314 to your computer and use it in GitHub Desktop.
import itertools
import sys
import mmstats
import mmstats.reader
class FastStats(mmstats.BaseMmStats):
a = mmstats.UInt64Field()
VALS = (0L, 9223372036854775807L, 18446744073709551615L)
def frobulate():
stats = FastStats(path='.', filename='frobulate.mmstats')
get = itertools.cycle(VALS).next
print 'frobulating... %s' % stats.filename
while 1:
stats.a = get()
def check():
reader = mmstats.reader.MmStatsReader.from_mmap('frobulate.mmstats')
vals = set(VALS)
i = 0
errors = 0
while 1:
i += 1
if i % 10000 == 0:
print '%10d checks done: %d errors' % (i, errors)
for stat in reader:
if stat.value not in vals:
print 'BOGUS VALUE: %r' % stat.value
errors += 1
print '.'
if __name__ == '__main__':
if len(sys.argv) != 2:
print 'usage: frobulate.py frob --or-- check'
elif sys.argv[1] == 'frob':
frobulate()
elif sys.argv[1] == 'check':
check()
else:
print 'usage: frobulate.py frob --or-- check'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment