/[eiffelstudio]/trunk/eweasel/tests/bench021/test.e
ViewVC logotype

Contents of /trunk/eweasel/tests/bench021/test.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 100604 - (show annotations)
Fri Jul 14 10:21:27 2017 UTC (2 years, 1 month ago) by alexk
File size: 1917 byte(s)
Added an example to test performance of old expressions when exceptions cannot be raised.
1 class TEST
2
3 create
4 make
5
6 feature
7
8 make
9 local
10 start, stop: DATE_TIME
11 i: INTEGER
12 a: ARRAY [READABLE_STRING_32]
13 n: like max_count
14 do
15 a := (create {ARGUMENTS_32}).argument_array
16 if a.upper = 0 then
17 n := max_count
18 elseif a.upper = 1 and then a [1].is_integer then
19 n := a [1].to_integer
20 end
21 if n = 0 then
22 (create {EXCEPTIONS}).die (0)
23 elseif n < 0 then
24 exit ("Invalid argument, positive integer is expected.%N")
25 end
26 io.put_string ("Iterations: ")
27 io.put_integer (n)
28 io.put_new_line
29 create start.make_now_utc
30 create stop.make_now_utc
31
32 io.put_string ("Attribute in postcondition: ")
33 start.make_now_utc
34 from
35 i := n
36 until
37 i <= 0
38 loop
39 old_attribute_in_postcondition
40 i := i - 1
41 end
42 stop.make_now_utc
43 print (stop.relative_duration (start).fine_seconds_count.rounded)
44 io.put_string (" seconds")
45 io.put_new_line
46
47 io.put_string ("Attribute in body: ")
48 start.make_now_utc
49 from
50 i := n
51 until
52 i <= 0
53 loop
54 old_attribute_in_body
55 i := i - 1
56 end
57 stop.make_now_utc
58 print (stop.relative_duration (start).fine_seconds_count.rounded)
59 io.put_string (" seconds")
60 io.put_new_line
61 end
62
63 feature {NONE} -- Arguments
64
65 max_count: INTEGER = 100
66
67 arguments: ARRAYED_LIST [STRING_32]
68 once
69 create Result.make (1)
70 Result.extend ({STRING_32} "0")
71 end
72
73 feature {NONE} -- Termination
74
75 exit (message: STRING)
76 do
77 io.error.put_string (message)
78 io.error.put_new_line;
79 (create {EXCEPTIONS}).die (-1)
80 end
81
82 feature {NONE} -- Test
83
84 item: INTEGER
85 -- A value to be checkde in old expressions.
86
87 old_attribute_in_postcondition
88 -- Increment `item` and check the effect in the postcondition.
89 do
90 item := item + 1
91 ensure
92 item = old item + 1
93 end
94
95 old_attribute_in_body
96 -- Increment `item` using its old value in the body.
97 do
98 -- item := old item + 1
99 end
100
101 end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23