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 @@ + + + + {% block title %}Rond De Tafel + {% if sort == "new" %} + {{ block.super }} - Nieuwste spellen + {% elif sort == "upcoming" %} + {{ block.super }} - Binnenkort op de agenda + {% elif sort == "near-me" %} + {{ block.super }} - In mijn buurt + {% endif %} + {% endblock %} + + + + + + + + + + {% block opengraph %} + + + {% endblock %} + + + + + + + + {% block additional-head %}{% endblock %} + + + + + + + +
+
+ + + + +
+ +{% if sort == "new" %} +

Nieuwste spellen

+{% elif sort == "upcoming" %} +

Binnenkort op de agenda

+{% elif sort == "near-me" %} +

In mijn buurt

+{% endif %} + +{% if base.user %} +
+ Spellen die je zelf organiseert worden niet getoond op deze pagina. + Deze spellen zijn te vinden in je persoonlijk menu, onder Mijn spellen. +
+{% endif %} + +{% if sort == "near-me" and not base.user.location %} +
+ {% if base.user %} + Om deze functie te activeren moet je een adres ingeven bij Instellingen. + {% else %} + Om deze functie te activeren moet je eerst aanmelden. + Daarna kan je een adres ingeven bij Instellingen. + {% endif %} +
+ +{% elif activities %} + {% for activity in activities %} + + + + + +
+
{{ activity.name }}
+

+ + + {{ activity.shortDate }} + + {{ activity.longDate }} + + om {{ activity.time }} +
+ + + {{ activity.time }}
+
+ {{ activity.host.name }}
+ {{ activity.location.city }} + {% if base.user.location %} + ({{ activity.distance }}km) + {% endif %} +

+
+
+ {% endfor %} + +{% else %} +

Geen spellen gepland.

+{% endif %} +
+ + + + + + + {% block additional-body %}{% endblock %} + + + + + + {% block title %}Rond De Tafel + {% if sort == "new" %} + {{ block.super }} - Nieuwste spellen + {% elif sort == "upcoming" %} + {{ block.super }} - Binnenkort op de agenda + {% elif sort == "near-me" %} + {{ block.super }} - In mijn buurt + {% endif %} + {% endblock %} + + + + + + + + + + {% block opengraph %} + + + {% endblock %} + + + + + + + + {% block additional-head %}{% endblock %} + + + + + + + +
+
+ + + + +
+ +{% if sort == "new" %} +

Nieuwste spellen

+{% elif sort == "upcoming" %} +

Binnenkort op de agenda

+{% elif sort == "near-me" %} +

In mijn buurt

+{% endif %} + +{% if base.user %} +
+ Spellen die je zelf organiseert worden niet getoond op deze pagina. + Deze spellen zijn te vinden in je persoonlijk menu, onder Mijn spellen. +
+{% endif %} + +{% if sort == "near-me" and not base.user.location %} +
+ {% if base.user %} + Om deze functie te activeren moet je een adres ingeven bij Instellingen. + {% else %} + Om deze functie te activeren moet je eerst aanmelden. + Daarna kan je een adres ingeven bij Instellingen. + {% endif %} +
+ +{% elif activities %} + {% for activity in activities %} + + + + + +
+
{{ activity.name }}
+

+ + + {{ activity.shortDate }} + + {{ activity.longDate }} + + om {{ activity.time }} +
+ + + {{ activity.time }}
+
+ {{ activity.host.name }}
+ {{ activity.location.city }} + {% if base.user.location %} + ({{ activity.distance }}km) + {% endif %} +

+
+
+ {% endfor %} + +{% else %} +

Geen spellen gepland.

+{% endif %} +
+ + + + + + + {% block additional-body %}{% endblock %} + + + + + + {% block title %}Rond De Tafel + {% if sort == "new" %} + {{ block.super }} - Nieuwste spellen + {% elif sort == "upcoming" %} + {{ block.super }} - Binnenkort op de agenda + {% elif sort == "near-me" %} + {{ block.super }} - In mijn buurt + {% endif %} + {% endblock %} + + + + + + + + + + {% block opengraph %} + + + {% endblock %} + + + + + + + + {% block additional-head %}{% endblock %} + + + + + + + +
+
+ + + + +
+ +{% if sort == "new" %} +

Nieuwste spellen

+{% elif sort == "upcoming" %} +

Binnenkort op de agenda

+{% elif sort == "near-me" %} +

In mijn buurt

+{% endif %} + +{% if base.user %} +
+ Spellen die je zelf organiseert worden niet getoond op deze pagina. + Deze spellen zijn te vinden in je persoonlijk menu, onder Mijn spellen. +
+{% endif %} + +{% if sort == "near-me" and not base.user.location %} +
+ {% if base.user %} + Om deze functie te activeren moet je een adres ingeven bij Instellingen. + {% else %} + Om deze functie te activeren moet je eerst aanmelden. + Daarna kan je een adres ingeven bij Instellingen. + {% endif %} +
+ +{% elif activities %} + {% for activity in activities %} + + + + + +
+
{{ activity.name }}
+

+ + + {{ activity.shortDate }} + + {{ activity.longDate }} + + om {{ activity.time }} +
+ + + {{ activity.time }}
+
+ {{ activity.host.name }}
+ {{ activity.location.city }} + {% if base.user.location %} + ({{ activity.distance }}km) + {% endif %} +

+
+
+ {% endfor %} + +{% else %} +

Geen spellen gepland.

+{% endif %} +
+ + + + + + + {% block additional-body %}{% endblock %} + +