File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,10 @@ let package = Package(
10
10
targets: [
11
11
. executableTarget(
12
12
name: " Benchmarks " ,
13
- dependencies: [ " JavaScriptKit " ] ,
13
+ dependencies: [
14
+ " JavaScriptKit " ,
15
+ . product( name: " JavaScriptFoundationCompat " , package : " JavaScriptKit " ) ,
16
+ ] ,
14
17
exclude: [ " Generated/JavaScript " , " bridge-js.d.ts " ] ,
15
18
swiftSettings: [
16
19
. enableExperimentalFeature( " Extern " )
Original file line number Diff line number Diff line change 1
1
import JavaScriptKit
2
+ import JavaScriptFoundationCompat
3
+ import Foundation
2
4
3
5
class Benchmark {
4
6
init ( _ title: String ) {
@@ -75,4 +77,22 @@ class Benchmark {
75
77
}
76
78
}
77
79
}
80
+
81
+ do {
82
+ let conversion = Benchmark ( " Conversion " )
83
+ let data = Data ( repeating: 0 , count: 10_000 )
84
+ conversion. testSuite ( " Data to JSTypedArray " ) {
85
+ for _ in 0 ..< 1_000_000 {
86
+ _ = data. jsTypedArray
87
+ }
88
+ }
89
+
90
+ let uint8Array = data. jsTypedArray
91
+
92
+ conversion. testSuite ( " JSTypedArray to Data " ) {
93
+ for _ in 0 ..< 1_000_000 {
94
+ _ = Data . construct ( from: uint8Array)
95
+ }
96
+ }
97
+ }
78
98
}
You can’t perform that action at this time.
0 commit comments