File tree 4 files changed +492
-0
lines changed
4 files changed +492
-0
lines changed Original file line number Diff line number Diff line change @@ -39,4 +39,20 @@ BenchmarkConjunctionDouble-16 17859 335044 ns/op
39
39
BenchmarkConjunctionSingle-16 19837 287302 ns/op
40
40
PASS
41
41
ok github.com/harpratap/cue-perf-tests 25.784s
42
+ ```
43
+
44
+ ## 3. Openness
45
+
46
+ Definitions are by default closed, but adding ellipses ` ... ` will open them. When importing OpenAPI spec to CUE it defaults to open definitions, which will cause export times to slow down
47
+
48
+ ```
49
+ go test -bench=BenchmarkDefinition
50
+ goos: darwin
51
+ goarch: amd64
52
+ pkg: github.com/harpratap/cue-perf-tests
53
+ cpu: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
54
+ BenchmarkDefinitionOpen-16 1404 800391 ns/op
55
+ BenchmarkDefinitionClosed-16 1635 770721 ns/op
56
+ PASS
57
+ ok github.com/harpratap/cue-perf-tests 3.130s
42
58
```
Original file line number Diff line number Diff line change @@ -7,4 +7,6 @@ func main() {
7
7
listComprehensionShort10 ()
8
8
conjunctionSingle ()
9
9
conjunctionDouble ()
10
+ definitionOpen ()
11
+ defintionClosed ()
10
12
}
Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "fmt"
5
+
6
+ "cuelang.org/go/cue"
7
+ "cuelang.org/go/cue/cuecontext"
8
+ )
9
+
10
+ const openSchema = `
11
+ #def1: {
12
+ text: string
13
+ text1?: string
14
+ text2?: string
15
+ text3?: string
16
+ text4?: string
17
+ ...
18
+ }
19
+
20
+ #def2: {
21
+ text: string
22
+ text1?: string
23
+ text2?: string
24
+ text3?: string
25
+ text4?: string
26
+ ...
27
+ }
28
+
29
+ #def3: {
30
+ text: string
31
+ text1?: string
32
+ text2?: string
33
+ text3?: string
34
+ text4?: string
35
+ ...
36
+ }
37
+
38
+ #def4: {
39
+ text: string
40
+ text1?: string
41
+ text2?: string
42
+ text3?: string
43
+ text4?: string
44
+ ...
45
+ }
46
+
47
+ #def5: {
48
+ text: string
49
+ text1?: string
50
+ text2?: string
51
+ text3?: string
52
+ text4?: string
53
+ ...
54
+ }
55
+
56
+ #def6: {
57
+ text: string
58
+ text1?: string
59
+ text2?: string
60
+ text3?: string
61
+ text4?: string
62
+ ...
63
+ }
64
+
65
+ #def7: {
66
+ text: string
67
+ text1?: string
68
+ text2?: string
69
+ text3?: string
70
+ text4?: string
71
+ ...
72
+ }
73
+
74
+ #def8: {
75
+ text: string
76
+ text1?: string
77
+ text2?: string
78
+ text3?: string
79
+ text4?: string
80
+ ...
81
+ }
82
+
83
+ #def9: {
84
+ text: string
85
+ text1?: string
86
+ text2?: string
87
+ text3?: string
88
+ text4?: string
89
+ ...
90
+ }
91
+
92
+ #def10: {
93
+ text: string
94
+ text1?: string
95
+ text2?: string
96
+ text3?: string
97
+ text4?: string
98
+ ...
99
+ }
100
+ #def11: {
101
+ text: string
102
+ text1?: string
103
+ text2?: string
104
+ text3?: string
105
+ text4?: string
106
+ ...
107
+ }
108
+
109
+ #def12: {
110
+ text: string
111
+ text1?: string
112
+ text2?: string
113
+ text3?: string
114
+ text4?: string
115
+ ...
116
+ }
117
+
118
+ #def13: {
119
+ text: string
120
+ text1?: string
121
+ text2?: string
122
+ text3?: string
123
+ text4?: string
124
+ ...
125
+ }
126
+
127
+ #def14: {
128
+ text: string
129
+ text1?: string
130
+ text2?: string
131
+ text3?: string
132
+ text4?: string
133
+ ...
134
+ }
135
+
136
+ #def15: {
137
+ text: string
138
+ text1?: string
139
+ text2?: string
140
+ text3?: string
141
+ text4?: string
142
+ ...
143
+ }
144
+
145
+ #def16: {
146
+ text: string
147
+ text1?: string
148
+ text2?: string
149
+ text3?: string
150
+ text4?: string
151
+ ...
152
+ }
153
+
154
+ #def17: {
155
+ text: string
156
+ text1?: string
157
+ text2?: string
158
+ text3?: string
159
+ text4?: string
160
+ ...
161
+ }
162
+
163
+ #def18: {
164
+ text: string
165
+ text1?: string
166
+ text2?: string
167
+ text3?: string
168
+ text4?: string
169
+ ...
170
+ }
171
+
172
+ #def19: {
173
+ text: string
174
+ text1?: string
175
+ text2?: string
176
+ text3?: string
177
+ text4?: string
178
+ ...
179
+ }
180
+
181
+ #def20: {
182
+ text: string
183
+ text1?: string
184
+ text2?: string
185
+ text3?: string
186
+ text4?: string
187
+ ...
188
+ }
189
+ `
190
+
191
+ const closedSchema = `
192
+ #def1: {
193
+ text: string
194
+ text1?: string
195
+ text2?: string
196
+ text3?: string
197
+ text4?: string
198
+ }
199
+
200
+ #def2: {
201
+ text: string
202
+ text1?: string
203
+ text2?: string
204
+ text3?: string
205
+ text4?: string
206
+ }
207
+
208
+ #def3: {
209
+ text: string
210
+ text1?: string
211
+ text2?: string
212
+ text3?: string
213
+ text4?: string
214
+ }
215
+
216
+ #def4: {
217
+ text: string
218
+ text1?: string
219
+ text2?: string
220
+ text3?: string
221
+ text4?: string
222
+ }
223
+
224
+ #def5: {
225
+ text: string
226
+ text1?: string
227
+ text2?: string
228
+ text3?: string
229
+ text4?: string
230
+ }
231
+
232
+ #def6: {
233
+ text: string
234
+ text1?: string
235
+ text2?: string
236
+ text3?: string
237
+ text4?: string
238
+ }
239
+
240
+ #def7: {
241
+ text: string
242
+ text1?: string
243
+ text2?: string
244
+ text3?: string
245
+ text4?: string
246
+ }
247
+
248
+ #def8: {
249
+ text: string
250
+ text1?: string
251
+ text2?: string
252
+ text3?: string
253
+ text4?: string
254
+ }
255
+
256
+ #def9: {
257
+ text: string
258
+ text1?: string
259
+ text2?: string
260
+ text3?: string
261
+ text4?: string
262
+ }
263
+
264
+ #def10: {
265
+ text: string
266
+ text1?: string
267
+ text2?: string
268
+ text3?: string
269
+ text4?: string
270
+ }
271
+
272
+ #def11: {
273
+ text: string
274
+ text1?: string
275
+ text2?: string
276
+ text3?: string
277
+ text4?: string
278
+ }
279
+
280
+ #def12: {
281
+ text: string
282
+ text1?: string
283
+ text2?: string
284
+ text3?: string
285
+ text4?: string
286
+ }
287
+
288
+ #def13: {
289
+ text: string
290
+ text1?: string
291
+ text2?: string
292
+ text3?: string
293
+ text4?: string
294
+ }
295
+
296
+ #def14: {
297
+ text: string
298
+ text1?: string
299
+ text2?: string
300
+ text3?: string
301
+ text4?: string
302
+ }
303
+
304
+ #def15: {
305
+ text: string
306
+ text1?: string
307
+ text2?: string
308
+ text3?: string
309
+ text4?: string
310
+ }
311
+
312
+ #def16: {
313
+ text: string
314
+ text1?: string
315
+ text2?: string
316
+ text3?: string
317
+ text4?: string
318
+ }
319
+
320
+ #def17: {
321
+ text: string
322
+ text1?: string
323
+ text2?: string
324
+ text3?: string
325
+ text4?: string
326
+ }
327
+
328
+ #def18: {
329
+ text: string
330
+ text1?: string
331
+ text2?: string
332
+ text3?: string
333
+ text4?: string
334
+ }
335
+
336
+ #def19: {
337
+ text: string
338
+ text1?: string
339
+ text2?: string
340
+ text3?: string
341
+ text4?: string
342
+ }
343
+
344
+ #def20: {
345
+ text: string
346
+ text1?: string
347
+ text2?: string
348
+ text3?: string
349
+ text4?: string
350
+ }
351
+ `
352
+
353
+ const opennessVal = `
354
+ v1: #def1 & {
355
+ text: "hello"
356
+ }
357
+
358
+ v2: #def2 & {
359
+ text: "hello"
360
+ }
361
+
362
+ v3: #def3 & {
363
+ text: "hello"
364
+ }
365
+
366
+ v4: #def4 & {
367
+ text: "hello"
368
+ }
369
+
370
+ v5: #def5 & {
371
+ text: "hello"
372
+ }
373
+
374
+ v6: #def6 & {
375
+ text: "hello"
376
+ }
377
+
378
+ v7: #def7 & {
379
+ text: "hello"
380
+ }
381
+
382
+ v8: #def8 & {
383
+ text: "hello"
384
+ }
385
+
386
+ v9: #def9 & {
387
+ text: "hello"
388
+ }
389
+
390
+ v10: #def10 & {
391
+ text: "hello"
392
+ }
393
+
394
+ v11: #def11 & {
395
+ text: "hello"
396
+ }
397
+
398
+ v12: #def12 & {
399
+ text: "hello"
400
+ }
401
+
402
+ v13: #def13 & {
403
+ text: "hello"
404
+ }
405
+
406
+ v14: #def14 & {
407
+ text: "hello"
408
+ }
409
+
410
+ v15: #def15 & {
411
+ text: "hello"
412
+ }
413
+
414
+ v16: #def16 & {
415
+ text: "hello"
416
+ }
417
+
418
+ v17: #def17 & {
419
+ text: "hello"
420
+ }
421
+
422
+ v18: #def18 & {
423
+ text: "hello"
424
+ }
425
+
426
+ v19: #def19 & {
427
+ text: "hello"
428
+ }
429
+
430
+ v20: #def20 & {
431
+ text: "hello"
432
+ }
433
+ `
434
+
435
+ func definitionOpen () {
436
+ var (
437
+ c * cue.Context
438
+ s cue.Value
439
+ v cue.Value
440
+ )
441
+ c = cuecontext .New ()
442
+ s = c .CompileString (openSchema )
443
+ v = c .CompileString (opennessVal , cue .Scope (s ))
444
+ fmt .Sprint (v )
445
+ }
446
+
447
+ func defintionClosed () {
448
+ var (
449
+ c * cue.Context
450
+ s cue.Value
451
+ v cue.Value
452
+ )
453
+ c = cuecontext .New ()
454
+ s = c .CompileString (closedSchema )
455
+ v = c .CompileString (opennessVal , cue .Scope (s ))
456
+ fmt .Sprint (v )
457
+ }
Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "testing"
5
+ )
6
+
7
+ func BenchmarkDefinitionOpen (b * testing.B ) {
8
+ for n := 0 ; n < b .N ; n ++ {
9
+ definitionOpen ()
10
+ }
11
+ }
12
+
13
+ func BenchmarkDefinitionClosed (b * testing.B ) {
14
+ for n := 0 ; n < b .N ; n ++ {
15
+ defintionClosed ()
16
+ }
17
+ }
You can’t perform that action at this time.
0 commit comments