[Python-checkins] python/dist/src/Lib/test sortperf.py,1.10,1.11
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Thu, 01 Aug 2002 22:46:11 -0700
- Previous message: [Python-checkins] python/dist/src/Modules arraymodule.c,2.78,2.79 audioop.c,1.48,1.49 binascii.c,2.36,2.37 cmathmodule.c,2.31,2.32 cPickle.c,2.91,2.92 cryptmodule.c,2.13,2.14 cStringIO.c,2.36,2.37 dbmmodule.c,2.31,2.32 dlmodule.c,2.22,2.23 errnomodule.c,2.17,2.18 fcntlmodule.c,2.35,2.36 flmodule.c,1.50,1.51 fpectlmodule.c,2.16,2.17 fpetestmodule.c,2.7,2.8 gdbmmodule.c,2.34,2.35 grpmodule.c,2.18,2.19 imageop.c,2.27,2.28 main.c,1.66,1.67 mathmodule.c,2.68,2.69 md5module.c,2.32,2.33 mpzmodule.c,2.44,2.45 operator.c,2.21,2.22 pcremodule.c,2.32,2.33 posixmodule.c,2.250,2.251 pwdmodule.c,1.34,1.35 python.c,2.6,2.7 readline.c,2.51,2.52 regexmodule.c,1.48,1.49 resource.c,2.26,2.27 rgbimgmodule.c,2.25,2.26 rotormodule.c,2.36,2.37 shamodule.c,2.20,2.21 signalmodule.c,2.70,2.71 socketmodule.c,1.238,1.239 stropmodule.c,2.89,2.90 structmodule.c,2.55,2.56 symtablemodule.c,1.5,1.6 syslogmodule.c,2.18,2.19 termios.c,2.35,2.36 threadmodule.c,2.51,2.52 timemodule.c,2.130,2.131 timingmodule.c,2.10,2.11 xreadlinesmodule.c,1.11,1.12 xxmodule.c,2.30,2.31 xxsubtype.c,2.16,2.17 _codecsmodule.c,2.12,2.13 _cursesmodule.c,2.65,2.66 _curses_panel.c,1.12,1.13 _localemodule.c,2.34,2.35 _ssl.c,1.7,1.8 _weakref.c,1.16,1.17
- Next message: [Python-checkins] python/dist/src/Mac/Lib EasyDialogs.py,1.37,1.38
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv28185/python/Lib/test
Modified Files:
sortperf.py
Log Message:
New test %sort. This takes a sorted list, picks 1% of the list positions
at random, and replaces the elements at those positions with new random
values. I was pleasantly surprised by how fast this goes! It's hard to
conceive of an algorithm that could special-case for this effectively.
Plus it's exactly what happens if a burst of gamma rays corrupts your
sorted database on disk <wink>.
i 2**i *sort ... %sort
15 32768 0.18 ... 0.03
16 65536 0.24 ... 0.04
17 131072 0.53 ... 0.08
18 262144 1.17 ... 0.16
19 524288 2.56 ... 0.35
20 1048576 5.54 ... 0.77
Index: sortperf.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/sortperf.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** sortperf.py 21 Jul 2002 17:37:03 -0000 1.10
--- sortperf.py 2 Aug 2002 05:46:09 -0000 1.11
***************
*** 77,80 ****
--- 77,81 ----
3sort: ascending, then 3 random exchanges
+sort: ascending, then 10 random at the end
+ %sort: ascending, then randomly replace 1% of the elements w/ random values
~sort: many duplicates
=sort: all equal
***************
*** 82,86 ****
"""
! cases = tuple([ch + "sort" for ch in r"*\/3+~=!"])
fmt = ("%2s %7s" + " %6s"*len(cases))
print fmt % (("i", "2**i") + cases)
--- 83,87 ----
"""
! cases = tuple([ch + "sort" for ch in r"*\/3+%~=!"])
fmt = ("%2s %7s" + " %6s"*len(cases))
print fmt % (("i", "2**i") + cases)
***************
*** 106,109 ****
--- 107,115 ----
L[-10:] = [random.random() for dummy in range(10)]
doit(L) # +sort
+
+ # Replace 1% of the elements at random.
+ for dummy in xrange(n // 100):
+ L[random.randrange(n)] = random.random()
+ doit(L) # %sort
# Arrange for lots of duplicates.
- Previous message: [Python-checkins] python/dist/src/Modules arraymodule.c,2.78,2.79 audioop.c,1.48,1.49 binascii.c,2.36,2.37 cmathmodule.c,2.31,2.32 cPickle.c,2.91,2.92 cryptmodule.c,2.13,2.14 cStringIO.c,2.36,2.37 dbmmodule.c,2.31,2.32 dlmodule.c,2.22,2.23 errnomodule.c,2.17,2.18 fcntlmodule.c,2.35,2.36 flmodule.c,1.50,1.51 fpectlmodule.c,2.16,2.17 fpetestmodule.c,2.7,2.8 gdbmmodule.c,2.34,2.35 grpmodule.c,2.18,2.19 imageop.c,2.27,2.28 main.c,1.66,1.67 mathmodule.c,2.68,2.69 md5module.c,2.32,2.33 mpzmodule.c,2.44,2.45 operator.c,2.21,2.22 pcremodule.c,2.32,2.33 posixmodule.c,2.250,2.251 pwdmodule.c,1.34,1.35 python.c,2.6,2.7 readline.c,2.51,2.52 regexmodule.c,1.48,1.49 resource.c,2.26,2.27 rgbimgmodule.c,2.25,2.26 rotormodule.c,2.36,2.37 shamodule.c,2.20,2.21 signalmodule.c,2.70,2.71 socketmodule.c,1.238,1.239 stropmodule.c,2.89,2.90 structmodule.c,2.55,2.56 symtablemodule.c,1.5,1.6 syslogmodule.c,2.18,2.19 termios.c,2.35,2.36 threadmodule.c,2.51,2.52 timemodule.c,2.130,2.131 timingmodule.c,2.10,2.11 xreadlinesmodule.c,1.11,1.12 xxmodule.c,2.30,2.31 xxsubtype.c,2.16,2.17 _codecsmodule.c,2.12,2.13 _cursesmodule.c,2.65,2.66 _curses_panel.c,1.12,1.13 _localemodule.c,2.34,2.35 _ssl.c,1.7,1.8 _weakref.c,1.16,1.17
- Next message: [Python-checkins] python/dist/src/Mac/Lib EasyDialogs.py,1.37,1.38
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]