-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Change stats page to be a table
- Loading branch information
Showing
4 changed files
with
68 additions
and
38 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
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 |
---|---|---|
@@ -1,18 +1,27 @@ | ||
package quadtree | ||
|
||
import ( | ||
"fmt" | ||
) | ||
type Stats struct { | ||
Generation int | ||
Level int | ||
Population int | ||
CacheSize int | ||
CacheHit int | ||
CacheMiss int | ||
} | ||
|
||
func (s *Stats) CacheRatio() float32 { | ||
return float32(cacheHit) / float32(cacheMiss) | ||
} | ||
|
||
func (n *Node) Stats() string { | ||
func (n *Node) Stats() Stats { | ||
mu.Lock() | ||
defer mu.Unlock() | ||
s := fmt.Sprintln("Generation: ", generation) | ||
s += fmt.Sprintln("Level: ", n.Level) | ||
s += fmt.Sprintln("Population: ", n.Value) | ||
s += fmt.Sprintln("Cache Size: ", len(nodeMap)) | ||
s += fmt.Sprintln("Cache Hit: ", cacheHit) | ||
s += fmt.Sprintln("Cache Miss: ", cacheMiss) | ||
s += fmt.Sprintln("Cache Ratio:", float32(cacheHit)/float32(cacheMiss)) | ||
return s | ||
return Stats{ | ||
Generation: int(generation), | ||
Level: int(n.Level), | ||
Population: n.Value, | ||
CacheSize: len(nodeMap), | ||
CacheHit: int(cacheHit), | ||
CacheMiss: int(cacheMiss), | ||
} | ||
} |