File tree Expand file tree Collapse file tree 1 file changed +32
-24
lines changed Expand file tree Collapse file tree 1 file changed +32
-24
lines changed Original file line number Diff line number Diff line change 1
- # Write the benchmarking functions here.
2
- # See "Writing benchmarks" in the asv docs for more information.
1
+ import numpy as np
2
+ import numpy_financial as npf
3
3
4
4
5
- class TimeSuite :
6
- """
7
- An example benchmark that times the performance of various kinds
8
- of iterating over dictionaries in Python.
9
- """
10
- def setup (self ):
11
- self .d = {}
12
- for x in range (500 ):
13
- self .d [x ] = None
5
+ class Npv1DCashflow :
14
6
15
- def time_keys (self ):
16
- for key in self .d .keys ():
17
- pass
7
+ param_names = ["cashflow_length" ]
8
+ params = [
9
+ (10 , 100 , 1000 ),
10
+ ]
18
11
19
- def time_values (self ):
20
- for value in self .d .values ():
21
- pass
12
+ def __init__ (self ):
13
+ self .cashflows = None
22
14
23
- def time_range (self ):
24
- d = self .d
25
- for key in range (500 ):
26
- d [key ]
15
+ def setup (self , cashflow_length ):
16
+ rng = np .random .default_rng (0 )
17
+ self .cashflows = rng .standard_normal (cashflow_length )
27
18
19
+ def time_1d_cashflow (self , cashflow_length ):
20
+ npf .npv (0.08 , self .cashflows )
28
21
29
- class MemSuite :
30
- def mem_list (self ):
31
- return [0 ] * 256
22
+
23
+ class Npv2DCashflows :
24
+
25
+ param_names = ["n_cashflows" , "cashflow_lengths" ]
26
+ params = [
27
+ (10 , 100 , 1000 ),
28
+ (10 , 100 , 1000 ),
29
+ ]
30
+
31
+ def __init__ (self ):
32
+ self .cashflows = None
33
+
34
+ def setup (self , n_cashflows , cashflow_lengths ):
35
+ rng = np .random .default_rng (0 )
36
+ self .cashflows = rng .standard_normal ((n_cashflows , cashflow_lengths ))
37
+
38
+ def time_2d_cashflow (self , n_cashflows , cashflow_lengths ):
39
+ npf .npv (0.08 , self .cashflows )
You can’t perform that action at this time.
0 commit comments