File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }))
Original file line number Diff line number Diff line change 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+ ) ;
You can’t perform that action at this time.
0 commit comments