Skip to content

Commit

Permalink
midi benchmark running
Browse files Browse the repository at this point in the history
  • Loading branch information
iskandr committed Aug 14, 2013
1 parent 9244e09 commit 56cb5fb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 26 deletions.
12 changes: 2 additions & 10 deletions benchmarks/meteor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# contributed by Daniel Nanz, 2008-08-21

import optparse

import sys
import time
from bisect import bisect
Expand Down Expand Up @@ -141,13 +141,5 @@ def run_solve(n):
solutions = []
return solve(n, 0, free, curr_board, pieces_left, solutions)


from timed_test import TimedTest
import random
import unittest
class TestMeteor(TimedTest):
def test_meteor(self):
self.time_compare(run_solve, SOLVE_ARG, repeat=5)

if __name__ == '__main__':
unittest.main()
run_solve(SOLVE_ARG)
23 changes: 9 additions & 14 deletions benchmarks/midi_msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ def _print_signatures():
sig = build_signature(spec)
print('mido.new {}'.format(sig))


def _init():
"""
Initialize the module.
Expand All @@ -369,11 +370,13 @@ def _init():
_SPEC_LOOKUP[spec.type] = spec


_init()

def serialized_messages():

# Import like above, or just paste this at the end of msg.py
a = Message(0x80, channel=0, note=60, velocity=64)
b = Message(0x90, channel=0, note=60, velocity=126)
a = Message('note_off', channel=0, note=60, velocity=64)
b = Message('note_on', channel=0, note=60, velocity=126)
c = a.copy(note=62)
d = Message(0x92) # Create Message by status_byte
abytes = a.bytes()
Expand All @@ -382,17 +385,9 @@ def serialized_messages():
return abytes + bbytes + cbytes + d.bytes()


import timed_test
import unittest
class TestMsg(timed_test.TimedTest):
def test_init(self):
self.timed(_init, repeat=2000)

def test_serialized_message(self):
self.timed(serialized_messages, repeat=2000)


if __name__ == '__main__':
unittest.main()
if __name__ == '__main__':
for _ in xrange(2000):
serialized_messages()



2 changes: 1 addition & 1 deletion benchmarks/quicksort.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def qs(x):
import argparse
import random
randint = random.randint
parser = argparse.ArgumentParser(description="Quicksort benchamrk")
parser = argparse.ArgumentParser(description="Quicksort benchmark")
parser.add_argument('--length', type=int, default = 100000)
args = parser.parse_args()
n = args.length
Expand Down
16 changes: 15 additions & 1 deletion src/falcon/reval.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,19 @@ struct BuildClass: public RegOpImpl<RegOp<4>, BuildClass> {
}
};



struct StoreMap: public RegOpImpl<RegOp<3>, StoreMap> {
static f_inline void _eval(Evaluator *eval, RegisterFrame* frame,
RegOp<3>& op,
Register* registers) {
PyObject* dict = LOAD_OBJ(op.reg[0]);
PyObject* key = LOAD_OBJ(op.reg[1]);
PyObject* value = LOAD_OBJ(op.reg[2]);
PyDict_SetItem(dict, key, value);
}
};

struct PrintItem: public RegOpImpl<RegOp<2>, PrintItem> {
static void _eval(Evaluator *eval, RegisterFrame* frame, RegOp<2>& op, Register* registers) {
PyObject* v = LOAD_OBJ(op.reg[0]);
Expand Down Expand Up @@ -2000,6 +2013,8 @@ DEFINE_OP(BUILD_LIST, BuildList);
DEFINE_OP(BUILD_MAP, BuildMap);
DEFINE_OP(BUILD_SLICE, BuildSlice);

DEFINE_OP(STORE_MAP, StoreMap);

DEFINE_OP(PRINT_NEWLINE, PrintNewline);
DEFINE_OP(PRINT_NEWLINE_TO, PrintNewline);
DEFINE_OP(PRINT_ITEM, PrintItem);
Expand Down Expand Up @@ -2063,7 +2078,6 @@ BAD_OP(EXEC_STMT);
BAD_OP(WITH_CLEANUP);
BAD_OP(PRINT_EXPR);
BAD_OP(DELETE_SUBSCR);
BAD_OP(STORE_MAP);
BAD_OP(DELETE_SLICE);
BAD_OP(NOP);
BAD_OP(ROT_FOUR);
Expand Down

0 comments on commit 56cb5fb

Please sign in to comment.