diff options
| author | Paul Buetow <paul@buetow.org> | 2025-03-14 23:51:11 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-03-14 23:51:11 +0200 |
| commit | b3bbc7ae0ea6747686626d26d0e5484ed06f49fe (patch) | |
| tree | 822c47f84326f9920e503ca040338b249ccceb0f | |
| parent | 5cac6a84181a6121e27c5c763a3e34254180fa4b (diff) | |
unexport types
| -rw-r--r-- | internal/file/file.go | 39 | ||||
| -rw-r--r-- | internal/flamegraph/flamegraph.go | 1 |
2 files changed, 21 insertions, 19 deletions
diff --git a/internal/file/file.go b/internal/file/file.go index a9de8d3..31c119e 100644 --- a/internal/file/file.go +++ b/internal/file/file.go @@ -13,27 +13,27 @@ type File interface { Name() string } -type FdFile struct { +type fdFile struct { fd int32 name string } -func NewFd(fd int32, name []byte) FdFile { - return FdFile{fd, stringValue(name)} +func NewFd(fd int32, name []byte) fdFile { + return fdFile{fd, stringValue(name)} } -func NewFdWithPid(fd int32, pid uint32) FdFile { +func NewFdWithPid(fd int32, pid uint32) fdFile { if linkName, err := os.Readlink(fmt.Sprintf("/proc/%d/fd/%d", pid, fd)); err == nil { - return FdFile{fd, linkName} + return fdFile{fd, linkName} } - return FdFile{fd, "?"} + return fdFile{fd, "?"} } -func (f FdFile) Name() string { +func (f fdFile) Name() string { return f.name } -func (f FdFile) String() string { +func (f fdFile) String() string { var sb strings.Builder if len(f.name) == 0 { @@ -48,19 +48,19 @@ func (f FdFile) String() string { return sb.String() } -type OldnameNewnameFile struct { +type oldnameNewnameFile struct { Oldname, Newname string } -func NewOldnameNewname(oldname, newname []byte) OldnameNewnameFile { - return OldnameNewnameFile{stringValue(oldname), stringValue(newname)} +func NewOldnameNewname(oldname, newname []byte) oldnameNewnameFile { + return oldnameNewnameFile{stringValue(oldname), stringValue(newname)} } -func (f OldnameNewnameFile) Name() string { +func (f oldnameNewnameFile) Name() string { return f.Newname } -func (f OldnameNewnameFile) String() string { +func (f oldnameNewnameFile) String() string { var sb strings.Builder sb.WriteString("old:") @@ -71,19 +71,19 @@ func (f OldnameNewnameFile) String() string { return sb.String() } -type PathnameFile struct { +type pathnameFile struct { Pathname string } -func NewPathname(pathname []byte) PathnameFile { - return PathnameFile{stringValue(pathname)} +func NewPathname(pathname []byte) pathnameFile { + return pathnameFile{stringValue(pathname)} } -func (f PathnameFile) Name() string { +func (f pathnameFile) Name() string { return f.Pathname } -func (f PathnameFile) String() string { +func (f pathnameFile) String() string { var sb strings.Builder sb.WriteString("pathname:") @@ -92,7 +92,8 @@ func (f PathnameFile) String() string { return sb.String() } +// As data comes in from arrays, converted to slices, there will be null-bytes at the end.. func stringValue(byteStr []byte) string { - // TODO: Hopefully, this won't cause a panic when the filename is as long as the array itself + // TODO: Hopefully, this won't cause a panic when the filename is as long as the array itself. Unit test this! return string(byteStr[:bytes.IndexByte(byteStr, 0)]) } diff --git a/internal/flamegraph/flamegraph.go b/internal/flamegraph/flamegraph.go index 6c5df63..dc1af53 100644 --- a/internal/flamegraph/flamegraph.go +++ b/internal/flamegraph/flamegraph.go @@ -16,6 +16,7 @@ type counter struct { duration uint64 } +// TODO: Idea, show time spent between the syscalls (off syscalls) as well, but in a different color // TODO: Profile for CPU usage. If too slow, can fan out into multiple maps and // then merge at the end the maps. type Flamegraph struct { |
