Skip to content

Commit

Permalink
add benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
capjamesg committed Aug 8, 2024
1 parent fec8768 commit 5f62a0e
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: KGL Benchmark (1M queries)

on:
pull_request:
branches: [main]
push:
branches: [main]

jobs:
build-dev-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v4
- name: 🐍 Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
check-latest: true

- name: 📦 Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
pip install pytest
- name: 🧪 Test
env:
SITE_ENV: production
run: "python benchmark.py"
16 changes: 16 additions & 0 deletions benchmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import os
from kgl import KnowledgeGraph
import cProfile

TEST_ITERATIONS = 1_000_000

test_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "test")

kg = KnowledgeGraph().load_from_csv(os.path.join(test_dir, "data", "example.csv"))

def main():
for i in range(TEST_ITERATIONS):
kg.evaluate("{ James -> Likes }")

# save the profile results
cProfile.run("main()", sort="cumtime", filename="profile_results")

0 comments on commit 5f62a0e

Please sign in to comment.