-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
ifc_performance_test.py
189 lines (159 loc) · 6.12 KB
/
ifc_performance_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# ***************************************************************************
# * *
# * Copyright (c) 2023 Yorik van Havre <[email protected]> *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU General Public License (GPL) *
# * as published by the Free Software Foundation; either version 3 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with this program; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************
import os
import time
import FreeCAD
import unittest
import ifc_import
FILES = [
"IfcOpenHouse_IFC4.ifc",
"FZK_haus.ifc",
"schultz_residence.ifc",
"nineteen_plots.ifc",
"schependomlaan.ifc",
"king_arch.ifc",
"king_arch_full.ifc",
]
BBIM = ["00:00", "00:01", "00:04", "00:05", "00:05", "00:14", "00:36"]
class NativeIFCTest(unittest.TestCase):
results = []
def setUp(self):
# setting a new document to hold the tests
if FreeCAD.ActiveDocument:
if FreeCAD.ActiveDocument.Name != "IfcTest":
FreeCAD.newDocument("IfcTest")
else:
FreeCAD.newDocument("IfcTest")
FreeCAD.setActiveDocument("IfcTest")
def tearDown(self):
FreeCAD.closeDocument("IfcTest")
def test01_IfcOpenHouse_coin(self):
print("COIN MODE")
n = 0
t = import_file(n)
self.results.append(register(n, t))
def test02_IfcOpenHouse_coin(self):
n = 1
t = import_file(n)
self.results.append(register(n, t))
def test03_IfcOpenHouse_coin(self):
n = 2
t = import_file(n)
self.results.append(register(n, t))
def test04_IfcOpenHouse_coin(self):
n = 3
t = import_file(n)
self.results.append(register(n, t))
def test05_IfcOpenHouse_coin(self):
n = 4
t = import_file(n)
self.results.append(register(n, t))
def test06_IfcOpenHouse_coin(self):
n = 5
t = import_file(n)
self.results.append(register(n, t))
def test07_IfcOpenHouse_coin(self):
n = 6
t = import_file(n)
self.results.append(register(n, t))
def test08_IfcOpenHouse_coin(self):
print("SHAPE MODE")
n = 0
t = import_file(n, shape=True)
self.results.append(register(n, t, "shape"))
def test09_IfcOpenHouse_coin(self):
n = 1
t = import_file(n, shape=True)
self.results.append(register(n, t, "shape"))
def test10_IfcOpenHouse_coin(self):
n = 2
t = import_file(n, shape=True)
self.results.append(register(n, t, "shape"))
def test11_IfcOpenHouse_coin(self):
n = 3
t = import_file(n, shape=True)
self.results.append(register(n, t, "shape"))
def test12_IfcOpenHouse_coin(self):
n = 4
t = import_file(n, shape=True)
self.results.append(register(n, t, "shape"))
# def test13_IfcOpenHouse_coin(self):
# n = 5
# t = import_file(n, shape=True)
# self.results.append(register(n, t, "shape"))
# def test14_IfcOpenHouse_coin(self):
# n = 6
# t = import_file(n, shape=True)
# self.results.append(register(n, t, "shape"))
def testfinal(self):
print(
"| File | File size | Import time (coin) | Import time (shape) | BlenderBIM |"
)
print(
"| ---- | --------- | ------------------- | ------------------ | ---------- |"
)
for i in range(len(self.results)):
if self.results[i][0] == "coin":
l = [
self.results[i][1],
self.results[i][2],
self.results[i][3],
"Timed out",
self.results[i][4],
]
b = [
j
for j in range(len(self.results))
if self.results[j][0] == "shape"
and self.results[j][1] == self.results[i][1]
]
if b:
l[3] = self.results[b[0]][3]
print("| " + " | ".join(l) + " |")
def test():
"This is meant to be used from a terminal, to run the tests without the GUI"
print("COIN MODE")
for f in FILES:
d = FreeCAD.newDocument()
ifc_import.insert(
os.path.expanduser("~") + os.sep + f,
d.Name,
strategy=0,
shapemode=1,
switchwb=0,
silent=True,
)
def import_file(n, shape=False):
if shape:
shapemode = 0
else:
shapemode = 1
stime = time.time()
f = os.path.join(os.path.expanduser("~"), FILES[n])
ifc_import.insert(
f, "IfcTest", strategy=0, shapemode=shapemode, switchwb=0, silent=True
)
return "%02d:%02d" % (divmod(round(time.time() - stime, 1), 60))
def register(n, t, mode="coin"):
f = os.path.join(os.path.expanduser("~"), FILES[n])
fsize = round(os.path.getsize(f) / 1048576, 2)
return [mode, FILES[n], str(fsize) + " Mb", t, BBIM[n]]