Ejemplo n.º 1
0
    def test_uses_get_keys(self):
        db = Database(self.engine, self.config)
        db.put(r"1", r"one")
        db.put(r"2", r"two")

        self.formatter = r"<{}>,"

        self.key = r""
        db.get_keys(self.all_and_each)
        self.assertEqual(self.key_and_value, r"<1>,<2>,")

        db.stop()
Ejemplo n.º 2
0
def test_engine(engine, value):
    global count, path, failures

    print("\nTesting " + engine + " engine for " + str(count) +
          " keys, value size is " + str(len(value)) + "...")
    if os.path.isfile(path):
        os.remove(path)

    db = Database(
        engine, '{"path": \"' + str(path) +
        '\", "size": 1073741824, "force_create": 1}')
    print("Put (sequential series)")
    t1 = time.time()
    for i in range(0, count):
        db.put(str(i), value)
    print("   in " + str(time.time() - t1) + " sec(s)")

    print("Get (sequential series)")
    failures = 0
    t1 = time.time()
    for i in range(0, count):
        if db.get(str(i)) == None:
            failures += 1
    print("   in " + str(time.time() - t1) + " sec(s), failures=" +
          str(failures))

    print("Exists (sequential series)")
    failures = 0
    t1 = time.time()
    for i in range(0, count):
        if not db.exists(str(i)):
            failures += 1
    print("   in " + str(time.time() - t1) + " sec(s), failures=" +
          str(failures))

    print("All (one pass)")
    failures = count
    t1 = time.time()
    db.get_keys(func)
    print("   in " + str(time.time() - t1) + " sec(s), failures=" +
          str(failures))

    print("Each (one pass)")
    failures = count
    t1 = time.time()
    db.get_all(func)
    print("   in " + str(time.time() - t1) + " sec(s), failures=" +
          str(failures))

    db.stop()