diff --git a/.gitignore b/.gitignore index d4870c2..e1ce3ef 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ DerivedData/ .swiftpm/configuration/registries.json .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata .netrc -/.build-* \ No newline at end of file +/.build-* +/Benchmarks/.build \ No newline at end of file diff --git a/Benchmarks/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata b/Benchmarks/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/Benchmarks/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Benchmarks/.vscode/launch.json b/Benchmarks/.vscode/launch.json new file mode 100644 index 0000000..b86b1d9 --- /dev/null +++ b/Benchmarks/.vscode/launch.json @@ -0,0 +1,28 @@ +{ + "configurations": [ + { + "type": "lldb", + "request": "launch", + "sourceLanguages": [ + "swift" + ], + "args": [], + "cwd": "${workspaceFolder:Benchmarks}", + "name": "Debug OpenSwiftUIBenchmark", + "program": "${workspaceFolder:Benchmarks}/.build/debug/OpenSwiftUIBenchmark", + "preLaunchTask": "swift: Build Debug OpenSwiftUIBenchmark" + }, + { + "type": "lldb", + "request": "launch", + "sourceLanguages": [ + "swift" + ], + "args": [], + "cwd": "${workspaceFolder:Benchmarks}", + "name": "Release OpenSwiftUIBenchmark", + "program": "${workspaceFolder:Benchmarks}/.build/release/OpenSwiftUIBenchmark", + "preLaunchTask": "swift: Build Release OpenSwiftUIBenchmark" + } + ] +} \ No newline at end of file diff --git a/Benchmarks/.vscode/settings.json b/Benchmarks/.vscode/settings.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/Benchmarks/.vscode/settings.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/Benchmarks/OpenSwiftUIBenchmark/Sample.swift b/Benchmarks/OpenSwiftUIBenchmark/Sample.swift new file mode 100644 index 0000000..a99d8a5 --- /dev/null +++ b/Benchmarks/OpenSwiftUIBenchmark/Sample.swift @@ -0,0 +1,14 @@ +// +// Sample.swift +// +// +// Created by Kyle on 2024/1/4. +// + +import Benchmark + +let benchmarks = { + Benchmark("Minimal benchmark") { _ in + // measure something here + } +} diff --git a/Benchmarks/Package.resolved b/Benchmarks/Package.resolved new file mode 100644 index 0000000..209f016 --- /dev/null +++ b/Benchmarks/Package.resolved @@ -0,0 +1,122 @@ +{ + "pins" : [ + { + "identity" : "openfoundation", + "kind" : "remoteSourceControl", + "location" : "https://github.com/OpenSwiftUIProject/OpenFoundation", + "state" : { + "revision" : "cd2cdb300d53e3e68fda8b690a703a7c5096d9d0", + "version" : "0.0.2" + } + }, + { + "identity" : "opengraph", + "kind" : "remoteSourceControl", + "location" : "https://github.com/OpenSwiftUIProject/OpenGraph", + "state" : { + "branch" : "main", + "revision" : "6835ce0972f40ef76f1214dc0efc75ec19082631" + } + }, + { + "identity" : "package-benchmark", + "kind" : "remoteSourceControl", + "location" : "https://github.com/ordo-one/package-benchmark", + "state" : { + "revision" : "2e724bf526c980699ae0c4b7a470b51816a89e72", + "version" : "1.20.0" + } + }, + { + "identity" : "package-datetime", + "kind" : "remoteSourceControl", + "location" : "https://github.com/ordo-one/package-datetime", + "state" : { + "revision" : "d1242188c9f48aad297e6ca9b717776f8660bc31", + "version" : "1.0.2" + } + }, + { + "identity" : "package-histogram", + "kind" : "remoteSourceControl", + "location" : "https://github.com/ordo-one/package-histogram", + "state" : { + "revision" : "a69fa24d7b70421870cafa86340ece900489e17e", + "version" : "0.1.2" + } + }, + { + "identity" : "package-jemalloc", + "kind" : "remoteSourceControl", + "location" : "https://github.com/ordo-one/package-jemalloc", + "state" : { + "revision" : "e8a5db026963f5bfeac842d9d3f2cc8cde323b49", + "version" : "1.0.0" + } + }, + { + "identity" : "progress.swift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/ordo-one/Progress.swift", + "state" : { + "revision" : "29dc5dc29d8408f42878b832c7aae38a35ff26ee", + "version" : "1.0.3" + } + }, + { + "identity" : "swift-argument-parser", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-argument-parser", + "state" : { + "revision" : "c8ed701b513cf5177118a175d85fbbbcd707ab41", + "version" : "1.3.0" + } + }, + { + "identity" : "swift-atomics", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-atomics", + "state" : { + "revision" : "cd142fd2f64be2100422d658e7411e39489da985", + "version" : "1.2.0" + } + }, + { + "identity" : "swift-extras-json", + "kind" : "remoteSourceControl", + "location" : "https://github.com/swift-extras/swift-extras-json", + "state" : { + "revision" : "122b9454ef01bf89a4c190b8fd3717ddd0a2fbd0", + "version" : "0.6.0" + } + }, + { + "identity" : "swift-numerics", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-numerics", + "state" : { + "revision" : "0a5bc04095a675662cf24757cc0640aa2204253b", + "version" : "1.0.2" + } + }, + { + "identity" : "swift-system", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-system", + "state" : { + "revision" : "025bcb1165deab2e20d4eaba79967ce73013f496", + "version" : "1.2.1" + } + }, + { + "identity" : "texttable", + "kind" : "remoteSourceControl", + "location" : "https://github.com/ordo-one/TextTable", + "state" : { + "revision" : "a27a07300cf4ae322e0079ca0a475c5583dd575f", + "version" : "0.0.2" + } + } + ], + "version" : 2 +} diff --git a/Benchmarks/Package.swift b/Benchmarks/Package.swift new file mode 100644 index 0000000..521fb98 --- /dev/null +++ b/Benchmarks/Package.swift @@ -0,0 +1,31 @@ +// swift-tools-version: 5.9 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import Foundation +import PackageDescription + +let package = Package( + name: "OpenSwiftUIBenchmark", + platforms: [ + .macOS(.v13), + ], + products: [ + .executable(name: "OpenSwiftUIBenchmark", targets: ["OpenSwiftUIBenchmark"]), + ], + dependencies: [ + .package(url: "https://github.com/ordo-one/package-benchmark", from: "1.20.0"), + .package(path: "../"), + ], + targets: [ + .executableTarget( + name: "OpenSwiftUIBenchmark", + dependencies: [ + .product(name: "Benchmark", package: "package-benchmark"), + ], + path: "OpenSwiftUIBenchmark", + plugins: [ + .plugin(name: "BenchmarkPlugin", package: "package-benchmark"), + ] + ) + ] +) diff --git a/Benchmarks/README.md b/Benchmarks/README.md new file mode 100644 index 0000000..2130154 --- /dev/null +++ b/Benchmarks/README.md @@ -0,0 +1 @@ +BENCHMARK_DISABLE_JEMALLOC=1 swift run \ No newline at end of file