1 // Copyright 2012 Google, Inc. All rights reserved.
3 // Use of this source code is governed by a BSD-style license
4 // that can be found in the LICENSE file in the root of the source
7 // Package util provides shared utilities for all gopacket examples.
17 var cpuprofile = flag.String("cpuprofile", "", "Where to write CPU profile")
19 // Run starts up stuff at the beginning of a main function, and returns a
20 // function to defer until the function completes. It should be used like this:
28 if *cpuprofile != "" {
29 f, err := os.Create(*cpuprofile)
31 log.Fatalf("could not open cpu profile file %q", *cpuprofile)
33 pprof.StartCPUProfile(f)
35 pprof.StopCPUProfile()