-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f330eed
commit 6af5313
Showing
4 changed files
with
54 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package tester | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/coinbase/rosetta-cli/pkg/logger" | ||
) | ||
|
||
const ( | ||
// MemoryLoggingFrequency is the frequency that memory | ||
// usage stats are logged to the terminal. | ||
MemoryLoggingFrequency = 10 * time.Second | ||
) | ||
|
||
// LogMemoryLoop runs a loop that logs memory usage. | ||
func LogMemoryLoop( | ||
ctx context.Context, | ||
) error { | ||
ticker := time.NewTicker(MemoryLoggingFrequency) | ||
defer ticker.Stop() | ||
|
||
for { | ||
select { | ||
case <-ctx.Done(): | ||
logger.LogMemoryStats(ctx) | ||
return ctx.Err() | ||
case <-ticker.C: | ||
logger.LogMemoryStats(ctx) | ||
} | ||
} | ||
} |