forked from gohugoio/hugo
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Track cached partial executions and display more useful info when showing the hints output. Also group cache hints and counters together to the right of the timing measurements. Sample output: cumulative average maximum cache percent cached total duration duration duration potential cached count count template ---------- -------- -------- --------- ------- ------ ----- -------- 2.6973ms 674.325µs 857.3µs 0 0 0 4 _internal/_default/rss.xml 2.6295ms 657.375µs 861.3µs 0 0 0 4 _default/single.html 1.2563ms 314.075µs 381.5µs 0 0 0 4 news/single.html 799.2µs 399.6µs 573.3µs 0 0 0 2 _internal/_default/sitemap.xml 667.3µs 66.73µs 238.6µs 84 0 0 10 partials/header.html 656.7µs 328.35µs 459.4µs 0 0 0 2 _default/list.html 479.7µs 47.97µs 158µs 92 0 0 10 partials/head.html 323.3µs 323.3µs 323.3µs 0 0 0 1 _internal/alias.html 200.7µs 200.7µs 200.7µs 0 0 0 1 _internal/_default/sitemapindex.xml 36.1µs 6.016µs 32.6µs 100 33 2 6 partials/footer.html 27.4µs 13.7µs 26.7µs 0 0 0 2 index.html Fixes gohugoio#8375
- Loading branch information
1 parent
ea6bcd6
commit d162283
Showing
3 changed files
with
125 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright 2022 The Hugo Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package partials_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/gohugoio/hugo/hugolib" | ||
) | ||
|
||
func TestInclude(t *testing.T) { | ||
t.Parallel() | ||
|
||
files := ` | ||
-- config.toml -- | ||
baseURL = 'http://example.com/' | ||
-- layouts/index.html -- | ||
partial: {{ partials.Include "foo.html" . }} | ||
-- layouts/partials/foo.html -- | ||
foo | ||
` | ||
|
||
b := hugolib.NewIntegrationTestBuilder( | ||
hugolib.IntegrationTestConfig{ | ||
T: t, | ||
TxtarString: files, | ||
}, | ||
).Build() | ||
|
||
b.AssertFileContent("public/index.html", ` | ||
partial: foo | ||
`) | ||
} | ||
|
||
func TestIncludeCached(t *testing.T) { | ||
t.Parallel() | ||
|
||
files := ` | ||
-- config.toml -- | ||
baseURL = 'http://example.com/' | ||
-- layouts/index.html -- | ||
partialCached: {{ partials.IncludeCached "foo.html" . }} | ||
partialCached: {{ partials.IncludeCached "foo.html" . }} | ||
-- layouts/partials/foo.html -- | ||
foo | ||
` | ||
|
||
b := hugolib.NewIntegrationTestBuilder( | ||
hugolib.IntegrationTestConfig{ | ||
T: t, | ||
TxtarString: files, | ||
}, | ||
).Build() | ||
|
||
b.AssertFileContent("public/index.html", ` | ||
partialCached: foo | ||
partialCached: foo | ||
`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters