We're looking at CPU bandwidth control via CFS:
Program does number of iterations, in each iteration we burn CPU in small chunks until we get 5ms of real time spent. On each iteration we also print how much
| FILENAME=$(basename $(pwd)) | |
| go test -run=. -bench=. -cpuprofile=cpu.out -benchmem -memprofile=mem.out -trace trace.out | |
| go tool pprof -pdf $FILENAME.test cpu.out > cpu.pdf && open cpu.pdf | |
| go tool pprof -pdf --alloc_space $FILENAME.test mem.out > alloc_space.pdf && open alloc_space.pdf | |
| go tool pprof -pdf --alloc_objects $FILENAME.test mem.out > alloc_objects.pdf && open alloc_objects.pdf | |
| go tool pprof -pdf --inuse_space $FILENAME.test mem.out > inuse_space.pdf && open inuse_space.pdf | |
| go tool pprof -pdf --inuse_objects $FILENAME.test mem.out > inuse_objects.pdf && open inuse_objects.pdf | |
| go tool trace trace.out | |
| go-torch $FILENAME.test cpu.out -f ${FILENAME}_cpu.svg && open ${FILENAME}_cpu.svg |
We're looking at CPU bandwidth control via CFS:
Program does number of iterations, in each iteration we burn CPU in small chunks until we get 5ms of real time spent. On each iteration we also print how much
This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.
###Array ####Definition:
| // getComponent is a function that returns a promise for a component | |
| // It will not be called until the first mount | |
| function asyncComponent(getComponent) { | |
| return class AsyncComponent extends React.Component { | |
| static Component = null; | |
| state = { Component: AsyncComponent.Component }; | |
| componentWillMount() { | |
| if (!this.state.Component) { | |
| getComponent().then(Component => { |
| FROM golang:alpine AS build | |
| ADD . /go/src/github.com/my/project | |
| WORKDIR /go/src/github.com/my/project | |
| RUN go build -o /mybinary ./cmd/mybinary | |
| FROM alpine:latest |
| # Mac OS X Lion introduced a new, iOS-like context menu when you press and hold a key | |
| # that enables you to choose a character from a menu of options. If you are on Lion | |
| # try it by pressing and holding down 'e' in any app that uses the default NSTextField | |
| # for input. | |
| # | |
| # It's a nice feature and continues the blending of Mac OS X and iOS features. However, | |
| # it's a nightmare to deal with in Sublime Text if you're running Vintage (Vim) mode, | |
| # as it means you cannot press and hold h/j/k/l to move through your file. You have | |
| # to repeatedly press the keys to navigate. |
| ### Nginx upstart script | |
| ### source: http://serverfault.com/a/391737/70451 | |
| ### /etc/init/nginx.conf | |
| description "nginx http daemon" | |
| start on (filesystem and net-device-up IFACE=lo) | |
| stop on runlevel [!2345] | |
| env DAEMON=/usr/local/sbin/nginx |
| /* Exercise: Loops and Functions #43 */ | |
| package main | |
| import ( | |
| "fmt" | |
| "math" | |
| ) | |
| func Sqrt(x float64) float64 { | |
| z := float64(2.) |
| if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () { | |
| var Storage = function (type) { | |
| function createCookie(name, value, days) { | |
| var date, expires; | |
| if (days) { | |
| date = new Date(); | |
| date.setTime(date.getTime()+(days*24*60*60*1000)); | |
| expires = "; expires="+date.toGMTString(); |
| package main | |
| import ( | |
| "bufio" | |
| "encoding/csv" | |
| "encoding/json" | |
| "fmt" | |
| "io" | |
| "os" | |
| "path/filepath" |