Skip to content

Commit e658148

Browse files
jbrockmendeljreback
authored andcommitted
add benchmarks for timestamp parsing (#18698)
1 parent 27a64b2 commit e658148

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

asv_bench/benchmarks/timedelta.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
from .pandas_vb_common import *
2-
from pandas import to_timedelta, Timestamp
1+
import numpy as np
2+
import pandas as pd
3+
4+
from pandas import to_timedelta, Timestamp, Timedelta
35

46

57
class ToTimedelta(object):
@@ -67,8 +69,8 @@ class DatetimeAccessor(object):
6769
def setup(self):
6870
self.N = 100000
6971
self.series = pd.Series(
70-
pd.timedelta_range('1 days', periods=self.N, freq='h')
71-
)
72+
pd.timedelta_range('1 days', periods=self.N, freq='h'))
73+
7274
def time_dt_accessor(self):
7375
self.series.dt
7476

asv_bench/benchmarks/timestamp.py

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
1-
from pandas import to_timedelta, Timestamp
1+
from pandas import Timestamp
22
import pytz
33
import datetime
44

55

6+
class TimestampConstruction(object):
7+
# TODO: classmethod constructors: fromordinal, fromtimestamp...
8+
9+
def time_parse_iso8601_no_tz(self):
10+
Timestamp('2017-08-25 08:16:14')
11+
12+
def time_parse_iso8601_tz(self):
13+
Timestamp('2017-08-25 08:16:14-0500')
14+
15+
def time_parse_dateutil(self):
16+
Timestamp('2017/08/25 08:16:14 AM')
17+
18+
def time_parse_today(self):
19+
Timestamp('today')
20+
21+
def time_parse_now(self):
22+
Timestamp('now')
23+
24+
625
class TimestampProperties(object):
726
goal_time = 0.2
827

ci/lint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if [ "$LINT" ]; then
2424
echo "Linting setup.py DONE"
2525

2626
echo "Linting asv_bench/benchmarks/"
27-
flake8 asv_bench/benchmarks/ --exclude=asv_bench/benchmarks/[ghijoprst]*.py --ignore=F811
27+
flake8 asv_bench/benchmarks/ --exclude=asv_bench/benchmarks/[ghijoprs]*.py --ignore=F811
2828
if [ $? -ne "0" ]; then
2929
RET=1
3030
fi

0 commit comments

Comments
 (0)