Ticket #10532: bench1.sage

File bench1.sage, 1.1 KB (added by pernici, 8 years ago)

benchmark

Line 
1from time import time
2import sys
3
4try:
5  F = sys.argv[1]
6  N = int(sys.argv[2])
7  n = int(sys.argv[3])
8except:
9  print '''prog F N n
10  F = field: QQ, RR, GF7
11  N = multiplier of the precision
12  n = test number
13  '''
14  sys.exit()
15
16if F == 'QQ':
17    field = QQ
18elif F == 'RR':
19    field = RR
20elif F == 'GF7':
21    field = GF(7)
22else:
23   print 'field not allowed'
24   sys.exit()
25
26print 'using', field
27
28L.<a,b,c,d> = PowerSeriesRing(field,4)
29
30t0 = time()
31if n == 1:
32  s = (1 + 2*a + 3*b + 4*d + L(0).O(16*N))^-5
33elif n == 2:
34  s = (1 + a^3 + b^3 + c^4 + d^4 + L(0).O(15*N))^-20
35elif n == 3:
36  s = (-1/6*b^6*d^14 - 1/9*a^4*b^10*c^4*d^12 + b^10*c^11*d^21 - a*b^14*c^24*d^4 - 1/66*a^16*b^11*c^17 + L(0).O(50*N))^20
37elif n == 4:
38  s = (1 + 1/2*a + 3*b + 4*a*b + 1/5*a^2 + 5/6*b^2 + L(0).O(30*N))^-20
39elif n == 5:
40  s = (1+a^14*b^9+8/3*a^22*b^11-1/13*a^23*b^19+a^15*b^28+L(0).O(51*N))^-20
41elif n == 6:
42  s = (1 + a + b + a*b + a^2 + b^2 + L(0).O(30*N))^-20
43elif n == 7:
44  s = (1 + a + 2*b - a*b + 3*a^2 - b^2 + L(0).O(30*N))^-20
45elif n == 8:
46  s = (1+a+12*b-10*a*b+13*a^2-7*b^2+L(0).O(30*N))^-20
47t1 = time()
48print s
49print '%.2f' % (t1-t0)