forked from tmedwards/tweego
-
Notifications
You must be signed in to change notification settings - Fork 0
/
statsitics.go
52 lines (44 loc) · 1.4 KB
/
statsitics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
Copyright © 2014–2020 Thomas Michael Edwards. All rights reserved.
Use of this source code is governed by a Simplified BSD License which
can be found in the LICENSE file.
*/
package main
import (
"log"
)
// statistics are collected statistics about the compiled story.
type statistics struct {
files struct {
project []string // Project source files.
external []string // Both modules and the head file.
}
counts struct {
passages uint64 // Count of all passages.
storyPassages uint64 // Count of story passages.
storyWords uint64 // Count of story passage "words" (typing measurement style).
}
}
var stats = statistics{}
func statsAddProjectFile(filepath string) {
stats.files.project = append(stats.files.project, filepath)
}
func statsAddExternalFile(filepath string) {
stats.files.external = append(stats.files.external, filepath)
}
func statsLog() {
log.Print("Statistics")
log.Printf(" Total> Passages: %d", stats.counts.passages)
log.Printf(" Story> Passages: %d, Words: %d", stats.counts.storyPassages, stats.counts.storyWords)
}
func statsLogFiles() {
log.Println("Processed files (in order)")
log.Printf(" Project files: %d", len(stats.files.project))
for _, file := range stats.files.project {
log.Printf(" %s", file)
}
log.Printf(" External files: %d", len(stats.files.external))
for _, file := range stats.files.external {
log.Printf(" %s", file)
}
}