memcpu

command
v0.0.0-...-8a36715 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2016 License: Apache-2.0 Imports: 3 Imported by: 0

README

Benchmark Profiling

Using benchmarks you can profile your programs and see exactly where your performance or memory is being taken.

Profiling Commands

CPU Profiling
   go test -run none -bench . -benchtime 3s -benchmem -cpuprofile cpu.out
   go tool pprof benchmarks.test cpu.out
   
   (pprof) list algOne
   (pprof) web list algOne

   _Note that goroutines in "syscall" state consume an OS thread, other goroutines do not (except for goroutines that called runtime.LockOSThread, which is, unfortunately, not visible in the profile). Note that goroutines in "IO wait" state also do not consume threads, they are parked on non-blocking network poller (which uses epoll/kqueue/GetQueuedCompletionStatus to unpark goroutines later)._
Memory Profiling
    go test -run none -bench . -benchtime 3s -benchmem -memprofile mem.out
    go tool pprof -<PICK_MEM_PROFILE> benchmarks.test mem.out

    (pprof) list algOne
    (pprof) web list algOne

    // Useful to see current status of heap.
	-inuse_space  : Allocations live at the time of profile  	** default
	-inuse_objects: Number of bytes allocated at the time of profile

	// Useful to see pressure on heap over time.
	-alloc_space  : All allocations happened since program start
	-alloc_objects: Number of object allocated at the time of profile

	If you want to reduce memory consumption, look at the `-inuse_space` profile collected during
    normal program operation.
	
	If you want to improve execution speed, look at the `-alloc_objects` profile collected after
    significant running time or at program end.

Code Review

Profiling (Go Playground) | Profiling Test (Go Playground)


All material is licensed under the Apache License Version 2.0, January 2004.

Documentation

Overview

Sample program that takes a stream of bytes and looks for the bytes “elvis” and when they are found, replace them with “Elvis”. The code cannot assume that there are any line feeds or other delimiters in the stream and the code must assume that the stream is of any arbitrary length. The solution cannot meaningfully buffer to the end of the stream and then process the replacement.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL