Skip to content

Commit dbb8eb5

Browse files
[Autoloop: perf-comparison] Iteration 415: USFederalHolidayCalendar.holidays() benchmark
Run: https://github.com/githubnext/tsb/actions/runs/29882922346 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 6dfeac6 commit dbb8eb5

2 files changed

Lines changed: 61 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""
2+
Benchmark: pandas USFederalHolidayCalendar.holidays() over a 10-year range
3+
"""
4+
import json
5+
import time
6+
import pandas as pd
7+
from pandas.tseries.holiday import USFederalHolidayCalendar
8+
9+
WARMUP = 5
10+
ITERATIONS = 20
11+
12+
start_date = "2000-01-01"
13+
end_date = "2009-12-31"
14+
15+
for _ in range(WARMUP):
16+
cal = USFederalHolidayCalendar()
17+
cal.holidays(start_date, end_date)
18+
19+
t0 = time.perf_counter()
20+
for _ in range(ITERATIONS):
21+
cal = USFederalHolidayCalendar()
22+
cal.holidays(start_date, end_date)
23+
total = (time.perf_counter() - t0) * 1000 # ms
24+
25+
print(json.dumps({
26+
"function": "us_federal_holidays",
27+
"mean_ms": total / ITERATIONS,
28+
"iterations": ITERATIONS,
29+
"total_ms": total,
30+
}))
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* Benchmark: USFederalHolidayCalendar.holidays() over a 10-year range
3+
*/
4+
import { USFederalHolidayCalendar } from "../../src/index.js";
5+
6+
const WARMUP = 5;
7+
const ITERATIONS = 20;
8+
9+
const start_date = new Date("2000-01-01");
10+
const end_date = new Date("2009-12-31");
11+
12+
for (let i = 0; i < WARMUP; i++) {
13+
const cal = new USFederalHolidayCalendar();
14+
cal.holidays(start_date, end_date);
15+
}
16+
17+
const t0 = performance.now();
18+
for (let i = 0; i < ITERATIONS; i++) {
19+
const cal = new USFederalHolidayCalendar();
20+
cal.holidays(start_date, end_date);
21+
}
22+
const total = performance.now() - t0;
23+
24+
console.log(
25+
JSON.stringify({
26+
function: "us_federal_holidays",
27+
mean_ms: total / ITERATIONS,
28+
iterations: ITERATIONS,
29+
total_ms: total,
30+
}),
31+
);

0 commit comments

Comments
 (0)