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(
1010 targets: [
1111 . executableTarget(
1212 name: " Benchmarks " ,
13- dependencies: [ " JavaScriptKit " ] ,
13+ dependencies: [
14+ " JavaScriptKit " ,
15+ . product( name: " JavaScriptFoundationCompat " , package : " JavaScriptKit " ) ,
16+ ] ,
1417 exclude: [ " Generated/JavaScript " , " bridge-js.d.ts " ] ,
1518 swiftSettings: [
1619 . enableExperimentalFeature( " Extern " )
Original file line number Diff line number Diff line change 11import JavaScriptKit
2+ import JavaScriptFoundationCompat
3+ import Foundation
24
35class Benchmark {
46 init ( _ title: String ) {
@@ -75,4 +77,22 @@ class Benchmark {
7577 }
7678 }
7779 }
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+ }
7898}
You can’t perform that action at this time.
0 commit comments