diff --git a/Tests/StencilTests/LexerSpec.swift b/Tests/StencilTests/LexerSpec.swift index c772d30..ebc114e 100644 --- a/Tests/StencilTests/LexerSpec.swift +++ b/Tests/StencilTests/LexerSpec.swift @@ -1,6 +1,7 @@ -import XCTest +import PathKit import Spectre @testable import Stencil +import XCTest class LexerTests: XCTestCase { func testLexer() { @@ -115,4 +116,14 @@ class LexerTests: XCTestCase { } } } + + func testPerformance() throws { + let path = Path(#file) + ".." + "fixtures" + "huge.html" + let content: String = try path.read() + + measure { + let lexer = Lexer(templateString: content) + _ = lexer.tokenize() + } + } } diff --git a/Tests/StencilTests/XCTestManifests.swift b/Tests/StencilTests/XCTestManifests.swift index 84f6cce..73cf026 100644 --- a/Tests/StencilTests/XCTestManifests.swift +++ b/Tests/StencilTests/XCTestManifests.swift @@ -57,6 +57,7 @@ extension InheritenceTests { extension LexerTests { static let __allTests = [ ("testLexer", testLexer), + ("testPerformance", testPerformance), ] } diff --git a/Tests/StencilTests/fixtures/huge.html b/Tests/StencilTests/fixtures/huge.html new file mode 100644 index 0000000..c338ed6 --- /dev/null +++ b/Tests/StencilTests/fixtures/huge.html @@ -0,0 +1,1131 @@ + + +
+
+
+
+ {{ activity.shortDate }}
+
+ {{ activity.longDate }}
+
+ om {{ activity.time }}
+
+
+
+ {{ activity.time }}
+
+ {{ activity.host.name }}
+ {{ activity.location.city }}
+ {% if base.user.location %}
+ ({{ activity.distance }}km)
+ {% endif %}
+
Geen spellen gepland.
+{% endif %} +
+
+
+ {{ activity.shortDate }}
+
+ {{ activity.longDate }}
+
+ om {{ activity.time }}
+
+
+
+ {{ activity.time }}
+
+ {{ activity.host.name }}
+ {{ activity.location.city }}
+ {% if base.user.location %}
+ ({{ activity.distance }}km)
+ {% endif %}
+
Geen spellen gepland.
+{% endif %} +
+
+
+ {{ activity.shortDate }}
+
+ {{ activity.longDate }}
+
+ om {{ activity.time }}
+
+
+
+ {{ activity.time }}
+
+ {{ activity.host.name }}
+ {{ activity.location.city }}
+ {% if base.user.location %}
+ ({{ activity.distance }}km)
+ {% endif %}
+
Geen spellen gepland.
+{% endif %} +