Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitda1675f

Browse files
Add benchmarks for Data to JSValue and vice versa
1 parent1d99c0f commitda1675f

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

‎Benchmarks/Package.swift‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff 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")

‎Benchmarks/Sources/Benchmarks.swift‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import JavaScriptKit
2+
import JavaScriptFoundationCompat
3+
import Foundation
24

35
classBenchmark{
46
init(_ title:String){
@@ -75,4 +77,22 @@ class Benchmark {
7577
}
7678
}
7779
}
80+
81+
do{
82+
letconversion=Benchmark("Conversion")
83+
letdata=Data(repeating:0, count:10_000)
84+
conversion.testSuite("Data to JSTypedArray"){
85+
for_in0..<1_000_000{
86+
_= data.jsTypedArray
87+
}
88+
}
89+
90+
letuint8Array= data.jsTypedArray
91+
92+
conversion.testSuite("JSTypedArray to Data"){
93+
for_in0..<1_000_000{
94+
_=Data.construct(from: uint8Array)
95+
}
96+
}
97+
}
7898
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp