MCPcopy Create free account
hub / github.com/dbt-labs/ade-bench / create_database

Function create_database

scripts_python/profiling_statistics.py:26–140  ·  view source on GitHub ↗
(db_path: str)

Source from the content-addressed store, hash-verified

24
25
26def create_database(db_path: str) -> sqlite3.Connection:
27 conn = sqlite3.connect(db_path)
28 cursor = conn.cursor()
29
30 cursor.execute("""
31 CREATE TABLE IF NOT EXISTS profiling_runs (
32 id INTEGER PRIMARY KEY AUTOINCREMENT,
33 folder_name TEXT UNIQUE NOT NULL,
34 timestamp DATETIME,
35 execution_time_seconds REAL,
36 n_concurrent_trials INTEGER,
37 disable_diffs BOOLEAN,
38 agent_name TEXT,
39 cprofile_exists BOOLEAN,
40 flamegraph_exists BOOLEAN,
41 args_exists BOOLEAN,
42 total_function_calls INTEGER,
43 primitive_calls INTEGER,
44 total_time_seconds REAL,
45 created_at DATETIME DEFAULT CURRENT_TIMESTAMP
46 )
47 """)
48
49 cursor.execute("CREATE INDEX IF NOT EXISTS idx_runs_timestamp ON profiling_runs(timestamp)")
50 cursor.execute("CREATE INDEX IF NOT EXISTS idx_runs_agent_name ON profiling_runs(agent_name)")
51
52 cursor.execute("""
53 CREATE TABLE IF NOT EXISTS functions (
54 id INTEGER PRIMARY KEY AUTOINCREMENT,
55 filename TEXT NOT NULL,
56 line_number INTEGER NOT NULL,
57 function_name TEXT NOT NULL,
58 module_name TEXT,
59 is_builtin BOOLEAN,
60 UNIQUE(filename, line_number, function_name)
61 )
62 """)
63
64 cursor.execute("CREATE INDEX IF NOT EXISTS idx_functions_name ON functions(function_name)")
65 cursor.execute("CREATE INDEX IF NOT EXISTS idx_functions_filename ON functions(filename)")
66 cursor.execute("CREATE INDEX IF NOT EXISTS idx_functions_module ON functions(module_name)")
67
68 cursor.execute("""
69 CREATE TABLE IF NOT EXISTS function_stats (
70 id INTEGER PRIMARY KEY AUTOINCREMENT,
71 run_id INTEGER NOT NULL,
72 function_id INTEGER NOT NULL,
73 call_count INTEGER NOT NULL,
74 primitive_call_count INTEGER NOT NULL,
75 total_time REAL NOT NULL,
76 cumulative_time REAL NOT NULL,
77 time_per_call REAL,
78 cumulative_per_call REAL,
79 time_percentage REAL,
80 FOREIGN KEY (run_id) REFERENCES profiling_runs(id) ON DELETE CASCADE,
81 FOREIGN KEY (function_id) REFERENCES functions(id) ON DELETE CASCADE,
82 UNIQUE(run_id, function_id)
83 )

Callers 1

run_profiling_and_importFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected