Start with cProfile to get a good overview of what's slow.
$ python -m cProfile -s cumulative your_code.py
-s to order by cumulative time
Example output:
#!usr/bin/env python2.7 | |
import pcbnew | |
""" | |
LED matrix layout creator. | |
NOTE: this currently assumes an even matrix, e.g. 16x16 as opposed to 15x15. | |
Will likely break in the latter case. |
#! /usr/bin/env python3 | |
import argparse | |
import math | |
from sys import argv | |
import matplotlib.pyplot as plt | |
import numpy as np | |
MIN_FREQ = 1 |
To hunt down memory leaks, you can use heapy.
$ pip install guppy
Example code:
from guppy import hpy
hp = hpy()
h = hp.heap()
<html> | |
<head> | |
<script type="text/javascript"> | |
// Step 1: create an object that represents an order | |
var order = { | |
customerInfo: { | |
name: 'maggie' | |
}, | |
lineItems: [ |
I hereby claim:
To claim this, I am signing this object:
/code Chrome 35.0.1916.153 on OS X 10.9.3 | |
`_(...)` with a number: | |
lodash.min x 39,094,087 ops/sec ±1.75% (67 runs sampled) | |
underscore-min x 16,916,505 ops/sec ±1.78% (83 runs sampled) | |
lodash.min is 131% faster. | |
`_(...)` with an array: | |
lodash.min x 51,700,639 ops/sec ±4.95% (82 runs sampled) | |
underscore-min x 13,862,501 ops/sec ±0.55% (83 runs sampled) |
Function.prototype.curry = function () { | |
var fn = this, args = Array.prototype.slice.call(arguments); | |
return function () { | |
return fn.apply(this, args.concat(Array.prototype.slice.call(arguments))); | |
}; | |
}; | |
var add = (function(a, b) { return a +b; }).curry(2) |
#include <stdlib.h> | |
#include <stdio.h> | |
int HASH_SIZE = 10; | |
struct Node { | |
char *key; | |
char *value; | |
struct Node *next; | |
}; |
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | |
<title>Per_month_graph</title> | |
<script src="http://d3js.org/d3.v2.js"></script> | |
<style type="text/css" media="all"> | |
.chartText { | |
font: 5px sans-serif; | |
} |