Created
April 3, 2012 15:40
-
-
Save lukecampbell/2293011 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from matplotlib import pyplot as plt | |
def vals(s): | |
import re | |
pids = re.findall(r'\([0-9]+\)', s) | |
for i in xrange(len(pids)): | |
pids[i] = int(re.sub(r'(\(|\))','',pids[i])) | |
v = re.findall(r'[0-9]+\.[0-9]+',s) | |
v = map(float,v) | |
v = np.array(v) | |
v = v * pids[0] | |
return pids, v, len(v) | |
def p(s, mlen, ts): | |
num, its, N = vals(s) | |
points = list() | |
points.extend(zip([mlen] * N, [ts] * N,its * ts)) | |
for point in points: | |
plot_point(point) | |
persist('/tmp/points2.dat',points) | |
def plot_point(point): | |
import numpy as np | |
print point | |
msg_len = point[0] | |
num = point[1] | |
its = point[2] | |
color='red' | |
if msg_len == 4: | |
color='red' | |
elif msg_len == 8: | |
color='blue' | |
elif msg_len == 16: | |
color='green' | |
elif msg_len == 32: | |
color='cyan' | |
elif msg_len == 64: | |
color='#006600' | |
elif msg_len == 128: | |
color='#981BE0' | |
elif msg_len == 256: | |
color='magenta' | |
elif msg_len == 512: | |
color='#1BE09B' | |
elif msg_len == 1024: | |
color='#E0BC1B' | |
offset = (np.log2(msg_len) / 8.) | |
num += offset | |
plt.scatter(num,its,c=color) | |
def persist(filename, points): | |
with open(filename,'a') as f: | |
for point in points: | |
f.write('%d,%d,%3.3f\n' % (point[0], point[1], point[2])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gevent | |
from gevent.greenlet import Greenlet | |
from pyon.util.containers import DotDict | |
from pyon.net.transport import NameTrio | |
from pyon.net.endpoint import Publisher | |
from pyon.ion.transform import TransformBenchTesting as bench | |
import uuid | |
num = 1 | |
msg_len = 1024 | |
transforms = list() | |
pids = 1 | |
pub = Publisher(to_name=NameTrio('test_exchange',str(uuid.uuid4())[0:6])) | |
for i in xrange(num): | |
tbt=cc.proc_manager._create_service_instance(str(pids), 'tbt', 'prototype.transforms.linear', 'TransformInPlace', DotDict({'process':{'name':'tbt%d' % pids, 'transform_id':pids}})) | |
tbt.init() | |
tbt.start() | |
gevent.sleep(0.2) | |
pub.publish(list(xrange(msg_len))) | |
g = Greenlet(tbt.perf) | |
g.start() | |
transforms.append(tbt) | |
pids += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The transform.py module is a test script to launch a sudo transform process in a container in a scriptable way. It is a hack for testing with multiple sudo transforms in a single container.