def mfmri_different(num): return fmri.PkgFmri( "pkg:/SUNWttf-google-{0:d}@0.5.11,5.11-0.{1:d}:{2:0=8d}T233516Z". format(num, num, num)) collection = [] funcs = [ dotseq, dotseq_different, vers, vers_different, mfmri, mfmri_different ] for func in funcs: print("#", func.__name__) pid = os.fork() if pid == 0: startusage = misc.__getvmusage() n = 0 # Generate a good sized series of valid YYYYMMDD strings for y in range(1, 10000): for m in range(1, 10): for d in range(1, 2): n += 1 collection.append( func(int("{0:0=4d}{1:0=2d}{2:0=2d}".format(y, m, d)))) endusage = misc.__getvmusage() est = (endusage - startusage) // n print( func.__name__, "{0:d} rounds, estimated memory per object: {1:d} bytes".format( n, est))
def mfmri(num): return fmri.PkgFmri("pkg:/[email protected],5.11-0.121:20090816T233516Z") def mfmri_different(num): return fmri.PkgFmri("pkg:/SUNWttf-google-%[email protected],5.11-0.%d:%08dT233516Z" % (num, num, num)) collection = [] funcs = [dotseq, dotseq_different, vers, vers_different, mfmri, mfmri_different] for func in funcs: print "#", func.__name__ pid = os.fork() if pid == 0: startusage = misc.__getvmusage() n = 0 # Generate a good sized series of valid YYYYMMDD strings for y in xrange(1, 10000): for m in xrange(1, 10): for d in xrange(1, 2): n += 1 collection.append(func(int("%04d%02d%02d" % (y, m, d)))) endusage = misc.__getvmusage() est = (endusage - startusage) / n print func.__name__, "%d rounds, estimated memory per object: %d bytes" % (n, est) sys.exit(0) else: os.wait()