Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Commit a71cda9

Browse files
authored
Added e2e benchmark (#897)
1 parent 1804bd2 commit a71cda9

1 file changed

Lines changed: 97 additions & 0 deletions

File tree

benchmarks/exchange_benchmark.py

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# *****************************************************************************
2+
# Copyright (c) 2020, Intel Corporation All rights reserved.
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# *****************************************************************************
15+
16+
import pandas as pd
17+
import numba
18+
from contextlib import redirect_stdout
19+
import sys
20+
import os
21+
import time
22+
23+
import warnings
24+
25+
warnings.simplefilter("ignore")
26+
27+
# New York Stock Exchange dataset
28+
# Load Data from Kaggle platform https://www.kaggle.com/dgawlik/nyse#prices.csv
29+
30+
out = sys.stdout
31+
32+
33+
def numba_jit(*args, **kwargs):
34+
kwargs.update({'nopython': True, 'parallel': True})
35+
return numba.jit(*args, **kwargs)
36+
37+
38+
def process_data():
39+
t_all = time.time()
40+
df = pd.read_csv('prices.csv')
41+
42+
res = (df['open'] + df['close']).sum()
43+
44+
aver_volume = df["volume"].sum() / df["volume"].size
45+
46+
df['open'].fillna(-1, inplace=True)
47+
df['close'].fillna(-1, inplace=True)
48+
df['low'].fillna(-1, inplace=True)
49+
df['high'].fillna(-1, inplace=True)
50+
df['volume'].fillna(-1, inplace=True)
51+
52+
res = df['open'].max(skipna=True)
53+
54+
abs_series = df['high'].abs()
55+
56+
res = abs_series.min(skipna=True)
57+
58+
res = df['low'].floordiv(100000)
59+
res = df['high'].floordiv(100)
60+
res = df['volume'].floordiv(100)
61+
62+
res = df['open'].map(lambda x: x**2)
63+
64+
res = df['low'].std()
65+
66+
end_time = time.time() - t_all
67+
68+
return df, res, end_time
69+
70+
71+
sdc_process_data = numba_jit(process_data)
72+
73+
74+
def main():
75+
print("Run Pandas...")
76+
t_start = time.time()
77+
process_data()
78+
print("TOTAL Pandas time: ", time.time() - t_start)
79+
80+
f = open(os.devnull, 'w')
81+
82+
with redirect_stdout(f):
83+
t_start = time.time()
84+
sdc_process_data() # Warming up
85+
t_end = time.time() - t_start
86+
print("SDC WARM_UP time: ", t_end)
87+
88+
print("Run SDC...")
89+
t_start = time.time()
90+
df1, res, end_time = sdc_process_data()
91+
t_total = time.time() - t_start
92+
print("NO boxing SDC time: ", end_time)
93+
print("TOTAL SDC time: ", t_total)
94+
95+
96+
if __name__ == "__main__":
97+
main()

0 commit comments

Comments
 (0)