Skip to content

Commit a2d6dc6

Browse files
fixed Vaux benchmark problems by patching src via fork; some dynamic html performance testing
1 parent d80752f commit a2d6dc6

File tree

5 files changed

+19
-18
lines changed

5 files changed

+19
-18
lines changed

Benchmarks/Benchmarks/SwiftHTMLKit/SwiftHTMLKit.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ package struct SwiftHTMLKitTests : HTMLGenerator {
2222
)
2323
}
2424
package func dynamicHTML(_ context: HTMLContext) -> String {
25-
let qualities:String = context.user.qualities.map({ #li("\($0)") }).joined()
25+
var qualities:String = ""
26+
for quality in context.user.qualities {
27+
qualities += #li("\(quality)")
28+
}
2629
return #html(
2730
#body(
2831
#h1("\(context.heading)"),

Benchmarks/Benchmarks/Swim/Swim.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extension Node {
1616
return (name == "html" ? "<!DOCTYPE html>" : "") + "<" + name + attributes_string + ">" + (child?.rendered ?? "") + "</" + name + ">"
1717
case .text(let string): return string
1818
case .raw(let string): return string
19-
case .comment(let _): return ""
19+
case .comment(_): return ""
2020
case .documentType(let string): return string
2121
case .fragment(let children): return children.map({ $0.rendered }).joined()
2222
case .trim: return ""
@@ -40,17 +40,19 @@ package struct SwimTests : HTMLGenerator {
4040
}.rendered
4141
}
4242
package func dynamicHTML(_ context: HTMLContext) -> String {
43-
html {
43+
var test:[Node] = []
44+
for quality in context.user.qualities {
45+
test.append(li { quality } )
46+
}
47+
return html {
4448
body {
4549
h1 { context.heading }
4650
div(id: context.desc_id) {
4751
p { context.string }
4852
}
4953
h2 { context.user.details_heading }
5054
h3 { context.user.qualities_heading }
51-
ul(id: context.user.qualities_id) {
52-
context.user.qualities.map({ quality in li { quality} })
53-
}
55+
ul(id: context.user.qualities_id) { test }
5456
}
5557
}.rendered
5658
}

Benchmarks/Benchmarks/Vaux/Vaux.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77

88
import Utilities
9-
@testable import Vaux
9+
import Vaux
1010
import Foundation
1111

1212
extension HTML {
@@ -34,16 +34,12 @@ extension HTMLNode {
3434
if let child = self.child {
3535
string += child.render
3636
}
37-
return string + "</" + tag + ">" // Vaux doesn't take into account void elements
37+
return string + "</" + tag + ">" // Vaux doesn't take void elements into account
3838
}
3939
}
4040

4141
package struct VauxTests : HTMLGenerator {
42-
43-
let vaux:Vaux
44-
package init() {
45-
vaux = Vaux()
46-
}
42+
package init() {}
4743

4844
package func staticHTML() -> String {
4945
html {

Benchmarks/Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ let package = Package(
1919
.package(url: "https://github.com/JohnSundell/Plot", from: "0.14.0"),
2020
//.package(url: "https://github.com/toucansites/toucan", from: "1.0.0-alpha.1"), // unstable
2121
.package(url: "https://github.com/RandomHashTags/fork-Swim", branch: "main"),
22-
.package(url: "https://github.com/dokun1/Vaux", from: "0.2.0"),
22+
.package(url: "https://github.com/RandomHashTags/fork-Vaux", branch: "master"),
2323
.package(url: "https://github.com/vapor/leaf", from: "4.4.0"),
2424

2525
// networking
@@ -108,7 +108,7 @@ let package = Package(
108108
name: "TestVaux",
109109
dependencies: [
110110
"Utilities",
111-
.product(name: "Vaux", package: "Vaux")
111+
.product(name: "Vaux", package: "fork-vaux")
112112
],
113113
path: "Benchmarks/Vaux"
114114
),

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,14 @@ Use the `HTMLElementAttribute.event(<type>, "<value>")`.
148148

149149
## Benchmarks
150150
- Libraries tested
151-
- [BinaryBuilds/swift-html](https://github.com/BinaryBirds/swift-html) v1.7.0 (fixed version [here](https://github.com/RandomHashTags/fork-bb-swift-html))
151+
- [BinaryBuilds/swift-html](https://github.com/BinaryBirds/swift-html) v1.7.0 (patched version [here](https://github.com/RandomHashTags/fork-bb-swift-html))
152152
- [sliemeobn/elementary](https://github.com/sliemeobn/elementary) v0.3.4
153153
- [JohnSundell/Plot](https://github.com/JohnSundell/Plot) v0.14.0
154154
- [RandomHashTags/swift-htmlkit](https://github.com/RandomHashTags/swift-htmlkit) v0.5.0 (this library)
155155
- [pointfreeco/swift-html](https://github.com/pointfreeco/swift-html) v0.4.1
156-
- [robb/Swim](https://github.com/robb/Swim) v0.4.0 (fixed version [here](https://github.com/RandomHashTags/fork-Swim))
156+
- [robb/Swim](https://github.com/robb/Swim) v0.4.0 (patched version [here](https://github.com/RandomHashTags/fork-Swim))
157157
- [vapor-community/HTMLKit](https://github.com/vapor-community/HTMLKit) v2.8.1
158-
- [dokun1/Vaux](https://github.com/dokun1/Vaux) v0.2.0
158+
- [dokun1/Vaux](https://github.com/dokun1/Vaux) v0.2.0 (patched version [here](https://github.com/RandomHashTags/fork-Vaux))
159159

160160
Using iMac (i9 9900k, 72GB RAM, 2TB) with macOS 15.0 and the Swift 6 compiler.
161161

0 commit comments

Comments
 (0)