diff --git a/common/no_profile.go b/common/no_profile.go deleted file mode 100644 index cf9a6e4b0b..0000000000 --- a/common/no_profile.go +++ /dev/null @@ -1,24 +0,0 @@ -// +build !linux - -/* - * Copyright (C) 2018 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy ofthe License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specificlanguage governing permissions and - * limitations under the License. - * - */ - -package common - -// Profile start profiling loop -func Profile() { -} diff --git a/common/profile.go b/profiling/profiling.go similarity index 90% rename from common/profile.go rename to profiling/profiling.go index ed0048821e..9435934844 100644 --- a/common/profile.go +++ b/profiling/profiling.go @@ -17,7 +17,7 @@ * */ -package common +package profiling import ( "log" @@ -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) @@ -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) } @@ -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) } diff --git a/skydive_prof.go b/skydive_prof.go index 4a0ff02115..870a47c190 100644 --- a/skydive_prof.go +++ b/skydive_prof.go @@ -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() } diff --git a/tests/tests.go b/tests/tests.go index 0d2d96a62b..d1ef60fa6b 100644 --- a/tests/tests.go +++ b/tests/tests.go @@ -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 ( @@ -846,7 +847,7 @@ var initStandalone = false func runStandalone() { if profile { - go common.Profile() + go profiling.Profile("/tmp/skydive-test-") } server, err := analyzer.NewServerFromConfig()