Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
sunkafei committed Jul 15, 2023
1 parent e8e5c86 commit 6178749
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- [Remove](#remove)
- [Build](#build)
- [Query](#query)
- [Benchmark](#benchmark)

## Get Started
[Download](https://github.com/sunkafei/coffeedb/releases) CoffeeDB, put it under any folder, run `./coffeedb`, then CoffeeDB will create a database under this folder and start the service. By default, the service address is http://127.0.0.1:14920/coffeedb. All database operations are handled by the Post method of this address.
Expand Down Expand Up @@ -190,4 +191,14 @@ The following example means: select all objects whose `name` contains "coffee" a
```


You can find more use cases of the `query` operation in [Get Started](#get-started).
You can find more use cases of the `query` operation in [Get Started](#get-started).

## Benchmark
We tested the running time of a single keyword query under different data scales, as shown below.
|The amount of data|Query time|
|-|-|
|1GB|1.2ms|
|2GB|1.3ms|
|4GB|1.5ms|
|8GB|2.0ms|
Details can be found [here](test/benchmark.py).
7 changes: 7 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ void test() {
},
"fields": ["id"]
})"_json);
response(R"({
"operation": "query",
"constraints": {
"id": "cd"
},
"fields": {"id"}
})"_json);
//response(R"({"operation":"query", "constraints":{"id":"[1,20]"},"fields":["id"]})"_json);
}
int main(int argc, char *argv[]) {
Expand Down
52 changes: 52 additions & 0 deletions test/benchmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import requests
import json
import random
from time import time
total = 0
url = "http://127.0.0.1:14920/coffeedb"
def send(data):
global total
data = json.dumps(data, indent=4)
now = time()
result = requests.post(url, data)
total += time() - now
if result.text:
return json.loads(result.text)
send({
"operation": "clear"
})
print("Start Insert ...")
for i in range(32768):
val = ''.join(chr(random.randint(ord('a'), ord('z'))) for i in range(32768))
send({
"operation": "insert",
"data": {
"id": i,
"val": val
}
})
print(i)
print("Start Build ...")
send({
"operation": "build"
})
print("Start Query ...")
total = 0
for _ in range(10000):
val = ''.join(chr(random.randint(ord('a'), ord('z'))) for i in range(5))
result = send({
"operation": "query",
"constraints": {
"val": val
},
"fields": [
"id",
"$correlation"
]
})
print(_)
print(total, total / 10000)
# 1G: 12.011453866958618 0.0012011453866958618
# 2G: 13.251314878463745 0.0013251314878463744
# 4G: 15.354285717010498 0.0015354285717010497
# 8G: 19.76681089401245 0.001976681089401245

0 comments on commit 6178749

Please sign in to comment.