Exemple #1
0
from randstr import newid

try:
    os.remove(DBPATH)
except:
    pass
conn = sqlite3.connect(DBPATH)
print "created scratch new DB"

c = conn.cursor()
c.execute("create table tab1 (k text, v text)")

start_time = time.time()

for i in xrange(N):
    c.execute('insert into tab1 values (?,?)', (newid(i), str(i)))
    if COMMITSIZE > 0 and i % COMMITSIZE == 0:
        conn.commit()
conn.commit()

elapsed_time = time.time() - start_time

c.close()

#for r in c.execute('select k, v from tab1'):
#   print r

print "ok, inserted %d records in %.1f seconds, %d recs/sec" % (
    N, elapsed_time, round(float(N) / elapsed_time))
print
Exemple #2
0
import sys, time

N = int(sys.argv[1])

print "running test on Python map, ", "records = %d" % N

from randstr import newid

start_time = time.time()

db = {}

for i in xrange(N):
    db[newid(i)] = i

elapsed_time = time.time() - start_time

print "ok, inserted %d records in %.1f seconds, %d recs/sec" % (
    N, elapsed_time, round(float(N) / elapsed_time))
print
Exemple #3
0
if USEFILE:
   storage = FileStorage(os.path.join(DBPATH, 'Data.fs'))
else:
   storage = MappingStorage()

print "created scratch new DB"


db = DB(storage)
conn = db.open()
dbroot = conn.root()
dbroot['tab1'] = OOBTree()
tab1 = dbroot['tab1']

from randstr import newid

start_time = time.time()

for i in xrange(N):
   tab1[newid(i)] = str(i)
   if COMMITSIZE > 0 and i % COMMITSIZE == 0:
      transaction.commit()
transaction.commit()

elapsed_time = time.time() - start_time

db.close()

print "ok, inserted %d records in %.1f seconds, %d recs/sec" % (N, elapsed_time, round(float(N)/elapsed_time))
print
Exemple #4
0
import sys, time

N = int(sys.argv[1])

print "running test on Python map, ", "records = %d" % N

from randstr import newid


start_time = time.time()

db = {}

for i in xrange(N):
   db[newid(i)] = i

elapsed_time = time.time() - start_time

print "ok, inserted %d records in %.1f seconds, %d recs/sec" % (N, elapsed_time, round(float(N)/elapsed_time))
print
Exemple #5
0
from randstr import newid

try:
   os.remove(DBPATH)
except:
   pass
conn = sqlite3.connect(DBPATH)
print "created scratch new DB"

c = conn.cursor()
c.execute("create table tab1 (k text, v text)")

start_time = time.time()

for i in xrange(N):
   c.execute('insert into tab1 values (?,?)', (newid(i), str(i)))
   if COMMITSIZE > 0 and i % COMMITSIZE == 0:
      conn.commit()
conn.commit()

elapsed_time = time.time() - start_time

c.close()

#for r in c.execute('select k, v from tab1'):
#   print r


print "ok, inserted %d records in %.1f seconds, %d recs/sec" % (N, elapsed_time, round(float(N)/elapsed_time))
print
Exemple #6
0
if USEFILE:
    storage = FileStorage(os.path.join(DBPATH, 'Data.fs'))
else:
    storage = MappingStorage()

print "created scratch new DB"

db = DB(storage)
conn = db.open()
dbroot = conn.root()
dbroot['tab1'] = OOBTree()
tab1 = dbroot['tab1']

from randstr import newid

start_time = time.time()

for i in xrange(N):
    tab1[newid(i)] = str(i)
    if COMMITSIZE > 0 and i % COMMITSIZE == 0:
        transaction.commit()
transaction.commit()

elapsed_time = time.time() - start_time

db.close()

print "ok, inserted %d records in %.1f seconds, %d recs/sec" % (
    N, elapsed_time, round(float(N) / elapsed_time))
print
Exemple #7
0
import sys, time, random, shutil, leveldb

N = int(sys.argv[1])
COMMITSIZE = int(sys.argv[2])
DBPATH = '/tmp/leveldb2'

print "running test on LevelDB, ", "records = %d" % N, "commit size = %d" % COMMITSIZE

from randstr import newid

shutil.rmtree(DBPATH, ignore_errors = True)
db = leveldb.LevelDB(DBPATH)
print "create scratch new DB"

start_time = time.time()

for i in xrange(N):
   if COMMITSIZE > 0 and i % COMMITSIZE == 0:
      db.Put(newid(i), str(i), sync = True)
   else:
      db.Put(newid(i), str(i))

elapsed_time = time.time() - start_time

print "ok, inserted %d records in %.1f seconds, %d recs/sec" % (N, elapsed_time, round(float(N)/elapsed_time))
print