Skip to content

Commit

Permalink
added more time comparisons for c++ vs for loop python vs vectorized …
Browse files Browse the repository at this point in the history
…python
  • Loading branch information
WillhHoffman committed Sep 5, 2024
1 parent e001031 commit 6664167
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions tests/exact/timeTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import simsopt.field as vec
import time

N = 1000
D = 10000
N = 100
D = 1000

pos_points = np.random.uniform(150,1500, size = (N,3))
signs = np.random.choice([-1,1], size = (N,3))
Expand All @@ -19,10 +19,10 @@
norms = np.random.uniform(-1,1, size = (N,3))
dims = np.array([1,1,1])

# t41 = time.time()
# B4 = floop.B_direct(points, magPos, M, dims, phiThetas)
# t42 = time.time()
# print('for loop B_direct took t = ', t42 - t41,' s')
t41 = time.time()
B4 = floop.B_direct(points, magPos, M, dims, phiThetas)
t42 = time.time()
print('for loop B_direct took t = ', t42 - t41,' s')

tv1 = time.time()
Bv = vec.B_direct(points, magPos, M, dims, phiThetas)
Expand All @@ -32,4 +32,19 @@
tc1 = time.time()
Bc = sopp.B_direct(points, magPos, M, dims, phiThetas)
tc2 = time.time()
print('c++ B_direct took t = ', tc2 - tc1,' s')
print('c++ B_direct took t = ', tc2 - tc1,' s')

t41 = time.time()
B4 = floop.Acube(points, magPos, norms, dims, phiThetas)
t42 = time.time()
print('for loop A matrix took t = ', t42 - t41,' s')

tv1 = time.time()
Bv = vec.Acube(points, magPos, norms, dims, phiThetas)
tv2 = time.time()
print('vectorized A matrix took t = ', tv2 - tv1,' s')

tc1 = time.time()
Bc = sopp.Acube(points, magPos, norms, dims, phiThetas)
tc2 = time.time()
print('c++ A matrix took t = ', tc2 - tc1,' s')

0 comments on commit 6664167

Please sign in to comment.