Skip to content

Commit

Permalink
chore(minor): Reduce dependencies (#215)
Browse files Browse the repository at this point in the history
Reduce dependencies from 12->7;

Removing extras-json and instead use Foundations JSON - we have a Foundation dependency anyway and will hopefully soon move to the new swift-foundation.

Fold in Progress.Swift inline with the project instead of depending on Ordo tagged release version

Fold in BenchmarkClock to remove dependency on Ordo package-datetime, move to use `CLOCK_BOOTTIME`

Update NIO locks from upstream

Move Benchmarks to a separate embedded project a la SwiftNIO to allow it to use newer toolchain and remove dependencies

Remove DocC plugin dependency as it is done behind the scenes by SPI anyway
  • Loading branch information
hassila authored Jan 8, 2024
1 parent 98c28b2 commit c53cdca
Show file tree
Hide file tree
Showing 28 changed files with 1,392 additions and 406 deletions.
95 changes: 2 additions & 93 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,93 +1,2 @@
####################################################################
# DO NOT EDIT THIS FILE
# This is a master file maintained in https://github.com/ordo-one/public-repository-templates
#
# Add overrides into `swiftlint_refinement.yml` in the directory it self or
# .swiftlint.yml under the specific directory where the code is located
#
# Documentation is under https://github.com/realm/SwiftLint
####################################################################

included:
- Benchmarks
- Sources
- Tests
excluded:
analyzer_rules:
- unused_import
opt_in_rules:
- array_init
- attributes
- closure_end_indentation
- closure_spacing
- collection_alignment
- contains_over_filter_count
- contains_over_filter_is_empty
- contains_over_first_not_nil
- contains_over_range_nil_comparison
- discouraged_none_name
- discouraged_object_literal
- empty_collection_literal
- empty_count
- empty_string
- empty_xctest_method
- enum_case_associated_values_count
- explicit_init
- extension_access_modifier
- fallthrough
- fatal_error_message
- file_name
- first_where
- flatmap_over_map_reduce
- identical_operands
- joined_default_parameter
- last_where
- legacy_multiple
- literal_expression_end_indentation
- lower_acl_than_parent
- modifier_order
- nimble_operator
- nslocalizedstring_key
- number_separator
- object_literal
- operator_usage_whitespace
- overridden_super_call
- override_in_extension
- pattern_matching_keywords
- prefer_self_in_static_references
- prefer_self_type_over_type_of_self
- private_action
- private_outlet
- prohibited_interface_builder
- prohibited_super_call
- quick_discouraged_call
- quick_discouraged_focused_test
- quick_discouraged_pending_test
- reduce_into
- redundant_nil_coalescing
- redundant_type_annotation
- single_test_class
- sorted_first_last
- sorted_imports
- static_operator
- strong_iboutlet
- test_case_accessibility
- toggle_bool
- unavailable_function
- unneeded_parentheses_in_closure_argument
- unowned_variable_capture
- untyped_error_in_catch
- vertical_parameter_alignment_on_call
- vertical_whitespace_closing_braces
- vertical_whitespace_opening_braces
- xct_specific_matcher
- yoda_condition
line_length:
warning: 140
error: 140
ignores_comments: true
ignores_urls: true
ignores_function_declarations: true
ignores_interpolated_strings: true
identifier_name:
excluded: [id, i, j, k]
child_config: .swiftlint_refinement.yml
parent_config: .swiftlint_base.yml
93 changes: 93 additions & 0 deletions .swiftlint_base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
####################################################################
# DO NOT EDIT THIS FILE
# This is a master file maintained in https://github.com/ordo-one/public-repository-templates
#
# Add overrides into `swiftlint_refinement.yml` in the directory it self or
# .swiftlint.yml under the specific directory where the code is located
#
# Documentation is under https://github.com/realm/SwiftLint
####################################################################

included:
- Benchmarks
- Sources
- Tests
excluded:
analyzer_rules:
- unused_import
opt_in_rules:
- array_init
- attributes
- closure_end_indentation
- closure_spacing
- collection_alignment
- contains_over_filter_count
- contains_over_filter_is_empty
- contains_over_first_not_nil
- contains_over_range_nil_comparison
- discouraged_none_name
- discouraged_object_literal
- empty_collection_literal
- empty_count
- empty_string
- empty_xctest_method
- enum_case_associated_values_count
- explicit_init
- extension_access_modifier
- fallthrough
- fatal_error_message
- file_name
- first_where
- flatmap_over_map_reduce
- identical_operands
- joined_default_parameter
- last_where
- legacy_multiple
- literal_expression_end_indentation
- lower_acl_than_parent
- modifier_order
- nimble_operator
- nslocalizedstring_key
- number_separator
- object_literal
- operator_usage_whitespace
- overridden_super_call
- override_in_extension
- pattern_matching_keywords
- prefer_self_in_static_references
- prefer_self_type_over_type_of_self
- private_action
- private_outlet
- prohibited_interface_builder
- prohibited_super_call
- quick_discouraged_call
- quick_discouraged_focused_test
- quick_discouraged_pending_test
- reduce_into
- redundant_nil_coalescing
- redundant_type_annotation
- single_test_class
- sorted_first_last
- sorted_imports
- static_operator
- strong_iboutlet
- test_case_accessibility
- toggle_bool
- unavailable_function
- unneeded_parentheses_in_closure_argument
- unowned_variable_capture
- untyped_error_in_catch
- vertical_parameter_alignment_on_call
- vertical_whitespace_closing_braces
- vertical_whitespace_opening_braces
- xct_specific_matcher
- yoda_condition
line_length:
warning: 140
error: 140
ignores_comments: true
ignores_urls: true
ignores_function_declarations: true
ignores_interpolated_strings: true
identifier_name:
excluded: [id, i, j, k]
3 changes: 3 additions & 0 deletions .swiftlint_refinement.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
excluded:
- Sources/Benchmark/Progress
- Sources/Benchmark/NIOConcurrencyHelpers
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let benchmarks = {

Benchmark("BenchmarkClock-now") { benchmark in
for _ in benchmark.scaledIterations {
blackHole(BenchmarkClock.now)
blackHole(DateTime.BenchmarkClock.now)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@ import Benchmark
import Histogram

let benchmarks = {
let metrics = [.wallClock, .throughput] + .memory + .arc
let metrics: [BenchmarkMetric] = [
.wallClock,
.throughput,
.peakMemoryResident,
.contextSwitches,
.syscalls,
.cpuTotal,
.mallocCountTotal,
.allocatedResidentMemory,
.threads,
.threadsRunning
]
Benchmark.defaultConfiguration = .init(metrics: metrics,
scalingFactor: .mega,
maxDuration: .seconds(1),
Expand Down
77 changes: 77 additions & 0 deletions Benchmarks/Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"pins" : [
{
"identity" : "hdrhistogram-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/HdrHistogram/hdrhistogram-swift",
"state" : {
"revision" : "a69fa24d7b70421870cafa86340ece900489e17e",
"version" : "0.1.2"
}
},
{
"identity" : "package-datetime",
"kind" : "remoteSourceControl",
"location" : "https://github.com/ordo-one/package-datetime",
"state" : {
"revision" : "d1242188c9f48aad297e6ca9b717776f8660bc31",
"version" : "1.0.2"
}
},
{
"identity" : "package-jemalloc",
"kind" : "remoteSourceControl",
"location" : "https://github.com/ordo-one/package-jemalloc",
"state" : {
"revision" : "e8a5db026963f5bfeac842d9d3f2cc8cde323b49",
"version" : "1.0.0"
}
},
{
"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-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
}
78 changes: 78 additions & 0 deletions Benchmarks/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// swift-tools-version: 5.9

import class Foundation.ProcessInfo
import PackageDescription

// If the environment variable BENCHMARK_DISABLE_JEMALLOC is set, we'll build the package without Jemalloc support
let disableJemalloc = ProcessInfo.processInfo.environment["BENCHMARK_DISABLE_JEMALLOC"]

let package = Package(
name: "Benchmarks",
platforms: [.macOS(.v14), .iOS(.v17)],
dependencies: [
.package(path: "../"),
.package(url: "https://github.com/ordo-one/package-datetime", .upToNextMajor(from: "1.0.1")),
.package(url: "https://github.com/HdrHistogram/hdrhistogram-swift", .upToNextMajor(from: "0.1.0"))
],
targets: []
)

// Add benchmark targets separately

// Benchmark of the DateTime package (which can't depend on Benchmark as we'll get a circular dependency)
package.targets += [
.executableTarget(
name: "BenchmarkDateTime",
dependencies: [
.product(name: "Benchmark", package: "package-benchmark"),
.product(name: "DateTime", package: "package-datetime")
],
path: "Benchmarks/DateTime",
plugins: [
.plugin(name: "BenchmarkPlugin", package: "package-benchmark")
]
)
]

// Benchmark of the benchmark package
package.targets += [
.executableTarget(
name: "Basic",
dependencies: [
.product(name: "Benchmark", package: "package-benchmark")
],
path: "Benchmarks/Basic",
plugins: [
.plugin(name: "BenchmarkPlugin", package: "package-benchmark")
]
)
]

// Benchmark of the Histogram package
package.targets += [
.executableTarget(
name: "HistogramBenchmark",
dependencies: [
.product(name: "Benchmark", package: "package-benchmark"),
.product(name: "Histogram", package: "hdrhistogram-swift")
],
path: "Benchmarks/Histogram",
plugins: [
.plugin(name: "BenchmarkPlugin", package: "package-benchmark")
]
)
]

// Benchmark testing loading of p90 absolute thresholds
package.targets += [
.executableTarget(
name: "P90AbsoluteThresholdsBenchmark",
dependencies: [
.product(name: "Benchmark", package: "package-benchmark")
],
path: "Benchmarks/P90AbsoluteThresholds",
plugins: [
.plugin(name: "BenchmarkPlugin", package: "package-benchmark")
]
)
]
Loading

0 comments on commit c53cdca

Please sign in to comment.