@@ -2,15 +2,17 @@ using AcuteML, BenchmarkTools
2
2
3
3
# Type Definition
4
4
5
- @aml mutable struct Person " person" , check_course
5
+ @aml mutable struct Person
6
+ " person" , check_course
6
7
age:: UInt64 , " ~"
7
8
field, " study-field"
8
9
GPA:: Float64 = 4.5 , " ~" , GPAcheck
9
10
courses:: Vector{String} , " taken-courses"
10
11
id:: Int64 , att " ~"
11
12
end
12
13
13
- @aml mutable struct University doc " university"
14
+ @aml mutable struct University
15
+ doc " university"
14
16
name, att " university-name"
15
17
people:: Vector{Person} , " person"
16
18
end
34
36
# ###############################################################
35
37
# Benchmark
36
38
function creation ()
37
- P1 = Person (age= 24 , field= " Mechanical Engineering" , courses= [" Artificial Intelligence" , " Robotics" ], id = 1 )
39
+ P1 = Person (age = 24 , field = " Mechanical Engineering" , courses = [" Artificial Intelligence" , " Robotics" ], id = 1 )
38
40
39
- P2 = Person (age= 18 , field= " Computer Engineering" , GPA= 4 , courses= [" Julia" ], id = 2 )
41
+ P2 = Person (age = 18 , field = " Computer Engineering" , GPA = 4 , courses = [" Julia" ], id = 2 )
40
42
41
- U = University (name= " Julia University" , people= [P1, P2])
43
+ U = University (name = " Julia University" , people = [P1, P2])
42
44
43
45
return P1, P2, U
44
46
end
@@ -47,29 +49,29 @@ function mutability(P1, P2, U)
47
49
P1. age = UInt (22 )
48
50
# P1.courses = ["Artificial Intelligence", "Robotics", "Machine Design"]
49
51
50
- P2. GPA= 4.2 # mutability support
52
+ P2. GPA = 4.2 # mutability support
51
53
U. name = " MIT"
52
54
return P1, P2, U
53
55
end
54
56
55
57
function extraction ()
56
- xml= parsexml ("""
57
- <?xml version="1.0" encoding="UTF-8"?>
58
- <university university-name="MIT">
59
- <person id="1">
60
- <age>22</age>
61
- <study-field>Mechanical Engineering</study-field>
62
- <GPA>4.5</GPA>
63
- <taken-courses>Artificial Intelligence</taken-courses> <taken-courses>Robotics</taken-courses>
64
- </person>
65
- <person id="2">
66
- <age>18</age>
67
- <study-field>Computer Engineering</study-field>
68
- <GPA>4.2</GPA>
69
- <taken-courses>Julia</taken-courses>
70
- </person>
71
- </university>
72
- """ )
58
+ xml = parsexml ("""
59
+ <?xml version="1.0" encoding="UTF-8"?>
60
+ <university university-name="MIT">
61
+ <person id="1">
62
+ <age>22</age>
63
+ <study-field>Mechanical Engineering</study-field>
64
+ <GPA>4.5</GPA>
65
+ <taken-courses>Artificial Intelligence</taken-courses> <taken-courses>Robotics</taken-courses>
66
+ </person>
67
+ <person id="2">
68
+ <age>18</age>
69
+ <study-field>Computer Engineering</study-field>
70
+ <GPA>4.2</GPA>
71
+ <taken-courses>Julia</taken-courses>
72
+ </person>
73
+ </university>
74
+ """ )
73
75
U = University (xml)
74
76
end
75
77
@@ -80,54 +82,3 @@ P1, P2, U = creation();
80
82
@btime mutability ($ P1, $ P2, $ U);
81
83
82
84
@btime extraction ();
83
-
84
- #=
85
- Benchmark Result
86
-
87
- v 0.10
88
- # small bump in extraction is because of two additional hasmethod check in nodeparse. Using traits this will be fixed
89
-
90
- 8.899 μs (100 allocations: 3.61 KiB)
91
- 3.938 μs (66 allocations: 3.17 KiB)
92
- 308.500 μs (403 allocations: 16.33 KiB)
93
-
94
- V 0.9.2 - julia 1.4
95
-
96
- 10.000 μs (99 allocations: 3.39 KiB)
97
- 3.986 μs (66 allocations: 3.17 KiB)
98
- 281.099 μs (356 allocations: 14.53 KiB)
99
-
100
- V 0.8.2
101
-
102
- 9.800 μs (100 allocations: 3.41 KiB)
103
- 4.057 μs (66 allocations: 3.17 KiB)
104
- 275.499 μs (356 allocations: 14.53 KiB)
105
-
106
- -------------------------------------
107
- V 0.7
108
-
109
- 11.299 μs (108 allocations: 11.61 KiB)
110
- 5.267 μs (73 allocations: 11.36 KiB)
111
- 261.400 μs (371 allocations: 23.11 KiB)
112
-
113
- -------------------------------------
114
- V 0.6
115
- 9.099 μs (92 allocations: 11.34 KiB)
116
- 16.800 μs (72 allocations: 11.58 KiB)
117
- 474.400 μs (348 allocations: 22.61 KiB)
118
-
119
- -------------------------------------
120
- V0.5
121
- 9.200 μs (93 allocations: 11.36 KiB)
122
- 19.799 μs (72 allocations: 11.58 KiB)
123
- 489.401 μs (348 allocations: 22.61 KiB
124
-
125
- -------------------------------------
126
- V 0.4
127
-
128
- 9.999 μs (92 allocations: 11.34 KiB)
129
- 20.900 μs (72 allocations: 11.58 KiB)
130
- 493.499 μs (363 allocations: 23.23 KiB)
131
-
132
-
133
- =#
0 commit comments