Skip to content

Commit

Permalink
common: move profiling to its own package
Browse files Browse the repository at this point in the history
  • Loading branch information
lebauce committed Mar 3, 2020
1 parent a34e766 commit 99d6d53
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 31 deletions.
24 changes: 0 additions & 24 deletions common/no_profile.go

This file was deleted.

8 changes: 4 additions & 4 deletions common/profile.go → profiling/profiling.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
*/

package common
package profiling

import (
"log"
Expand All @@ -29,7 +29,7 @@ import (
)

// Profile start profiling loop
func Profile() {
func Profile(pathPrefix string) {
cpu := make(chan os.Signal, 1)
signal.Notify(cpu, syscall.SIGUSR1)

Expand All @@ -39,7 +39,7 @@ func Profile() {
for {
select {
case <-cpu:
f, err := os.Create("/tmp/skydive-cpu.prof")
f, err := os.Create(pathPrefix + "cpu.prof")
if err != nil {
log.Fatal("could not create CPU profile: ", err)
}
Expand All @@ -56,7 +56,7 @@ func Profile() {
case <-memory:
// Memory Profile
runtime.GC()
memProfile, err := os.Create("/tmp/skydive-memory.prof")
memProfile, err := os.Create(pathPrefix + "memory.prof")
if err != nil {
log.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions skydive_prof.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ package main

import (
"github.com/skydive-project/skydive/cmd/skydive"
"github.com/skydive-project/skydive/common"
"github.com/skydive-project/skydive/profiling"
)

func main() {
go common.Profile()
go profiling.Profile("/tmp/skydive-")

skydive.RootCmd.Execute()
}
3 changes: 2 additions & 1 deletion tests/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import (
g "github.com/skydive-project/skydive/gremlin"
shttp "github.com/skydive-project/skydive/http"
"github.com/skydive-project/skydive/logging"
"github.com/skydive-project/skydive/profiling"
)

const (
Expand Down Expand Up @@ -846,7 +847,7 @@ var initStandalone = false

func runStandalone() {
if profile {
go common.Profile()
go profiling.Profile("/tmp/skydive-test-")
}

server, err := analyzer.NewServerFromConfig()
Expand Down

0 comments on commit 99d6d53

Please sign in to comment.