File tree Expand file tree Collapse file tree 2 files changed +15
-13
lines changed
IntegrationTests/tests_04_performance/test_01_resources Expand file tree Collapse file tree 2 files changed +15
-13
lines changed Original file line number Diff line number Diff line change 73
73
- $GITHUB_WORKSPACE:/src
74
74
options : --workdir /src
75
75
env :
76
- MAX_ALLOCS_ALLOWED_jsonvalue_to_bytes : 1000
76
+ MAX_ALLOCS_ALLOWED_jsonvalue_to_bytes : 0
77
77
steps :
78
78
- name : Checkout
79
79
uses : actions/checkout@v1
Original file line number Diff line number Diff line change 1
1
import PureSwiftJSONParsing
2
2
3
3
func run( identifier: String ) {
4
- let sampleString = SampleStructure . sampleJSON
5
- let sampleBytes = [ UInt8] ( sampleString. utf8)
6
- let sampleJSON = try ! JSONParser ( ) . parse ( bytes: sampleBytes)
7
-
8
- measure ( identifier: identifier) {
9
- for _ in 0 ..< 1_000 {
10
- var bytes = [ UInt8] ( ) // <-- this is the only real allocation
11
- bytes. reserveCapacity ( 6000 ) // <-- reserve capactity so high we don't need reallocs
12
- sampleJSON. appendBytes ( to: & bytes)
13
- }
14
-
15
- return 1_000
4
+ let sampleString = SampleStructure . sampleJSON
5
+ let sampleBytes = [ UInt8] ( sampleString. utf8)
6
+ let sampleJSON = try ! JSONParser ( ) . parse ( bytes: sampleBytes)
7
+
8
+ var bytes = [ UInt8] ( ) // <-- this is the only real allocation
9
+ bytes. reserveCapacity ( 6000 ) // <-- reserve capactity so high we don't need reallocs
10
+
11
+ measure ( identifier: identifier) {
12
+ for _ in 0 ..< 1_000 {
13
+ bytes. removeAll ( keepingCapacity: true )
14
+ sampleJSON. appendBytes ( to: & bytes)
16
15
}
16
+
17
+ return 1_000
18
+ }
17
19
}
You can’t perform that action at this time.
0 commit comments