Skip to content

feat: improve query performance #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions tests/bench.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import os
import time

from stack_graphs_python import index, Querier, Position, Language

# index ./js_sample directory

# convert ./js_sample directory to absolute path
dir = os.path.abspath("./tests/js_sample")
db_path = os.path.abspath("./db.sqlite")

print("Indexing directory: ", dir)
print("Database path: ", db_path)

index([dir], db_path, language=Language.TypeScript)

source_reference = Position(path=dir + "/index.js", line=2, column=12)

print("Querying definition for: ", source_reference.path)

querier = Querier(db_path)


def run_n_queries(n):
start = time.time()
for i in range(n):
querier.definitions(source_reference)
end = time.time()
# delta in ms
delta = (end - start) * 1000
print(
f"{n} queries took: {delta}ms",
)


run_n_queries(100)
run_n_queries(1000)
run_n_queries(10000)
Loading