thesis version
This commit is contained in:
44
scripts/common.py
Normal file
44
scripts/common.py
Normal file
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import matplotlib.lines as lines
|
||||
|
||||
def set_size(width, fraction=1):
|
||||
""" Set aesthetic figure dimensions to avoid scaling in latex.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
width: float
|
||||
Width in pts (\\the\\textwidth)
|
||||
fraction: float
|
||||
Fraction of the width which you wish the figure to occupy
|
||||
|
||||
Returns
|
||||
-------
|
||||
fig_dim: tuple
|
||||
Dimensions of figure in inches
|
||||
"""
|
||||
# Width of figure
|
||||
fig_width_pt = width * fraction
|
||||
|
||||
# Convert from pt to inches
|
||||
inches_per_pt = 1 / 72.27
|
||||
|
||||
# Golden ratio to set aesthetic figure height
|
||||
golden_ratio = (5 ** 0.5 - 1) / 2
|
||||
|
||||
# Figure width in inches
|
||||
fig_width_in = fig_width_pt * inches_per_pt
|
||||
# Figure height in inches
|
||||
fig_height_in = fig_width_in * golden_ratio
|
||||
|
||||
return fig_width_in, fig_height_in
|
||||
|
||||
|
||||
def config_plt():
|
||||
plt.rc('font', size=11, family='Latin Modern Roman')
|
||||
plt.rc('text', usetex=True)
|
||||
plt.rc('xtick', labelsize=11)
|
||||
plt.rc('ytick', labelsize=11)
|
||||
plt.rc('axes', labelsize=11)
|
99
scripts/display_skeleton
Executable file
99
scripts/display_skeleton
Executable file
@ -0,0 +1,99 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import getopt
|
||||
import re
|
||||
|
||||
matching = {'<': '>', '(': ')'}
|
||||
|
||||
|
||||
def find_matching(block):
|
||||
o = block[0]
|
||||
c = matching[block[0]]
|
||||
i = 1
|
||||
d = 1
|
||||
while d != 0:
|
||||
if block[i] == o:
|
||||
d = d + 1
|
||||
elif block[i] == c:
|
||||
d = d - 1
|
||||
i = i + 1
|
||||
|
||||
return i
|
||||
|
||||
|
||||
def help(argv):
|
||||
cmd=argv[0]
|
||||
print(f"{cmd} [-h] [-l <limit>] [-f <filter>]...")
|
||||
|
||||
|
||||
def cli(argv):
|
||||
filters = []
|
||||
limit = 64
|
||||
substs = {
|
||||
'std::mersenne_twister_engine<[^>]*>': 'RNG',
|
||||
}
|
||||
try:
|
||||
opts, args = getopt.getopt(argv[1:], "hf:l:", ["limit=", "filter="])
|
||||
except getopt.GetoptError:
|
||||
help(argv)
|
||||
sys.exit(2)
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
help(argv)
|
||||
sys.exit()
|
||||
elif opt in ("-f", "--filter"):
|
||||
filters.append(arg)
|
||||
elif opt in ("-l", "--limit"):
|
||||
limit = int(arg)
|
||||
|
||||
return [filters, limit, substs]
|
||||
|
||||
|
||||
def process(limit, line, d = 0):
|
||||
i = 0
|
||||
print(" "*d, end='')
|
||||
while i < len(line):
|
||||
c = line[i]
|
||||
if c == '(':
|
||||
trail = line[i:]
|
||||
e = find_matching(trail)
|
||||
print(trail[:e], end='')
|
||||
i = i + e - 1
|
||||
elif c == '<':
|
||||
trail = line[i:]
|
||||
e = find_matching(trail)
|
||||
if e > limit:
|
||||
print("<")
|
||||
process(limit, trail[1:e-1], d+1)
|
||||
print("\n"+" "*d+">", end='')
|
||||
else:
|
||||
print(trail[:e], end='')
|
||||
i = i + e - 1
|
||||
elif c == ',':
|
||||
print(c)
|
||||
print(" "*d, end='')
|
||||
elif c != ' ':
|
||||
print(c, end='')
|
||||
|
||||
i = i + 1
|
||||
|
||||
|
||||
def applyReplaces(line, substs):
|
||||
for fr, to in substs.items():
|
||||
line = re.sub(fr, to, line)
|
||||
|
||||
return line
|
||||
|
||||
|
||||
[filters, limit, substs] = cli(sys.argv)
|
||||
lines = sys.stdin.readlines()
|
||||
lines = [item.rstrip() for item in lines if item != "\n"]
|
||||
data = "".join(lines)
|
||||
data = applyReplaces(data, substs)
|
||||
|
||||
for f in filters:
|
||||
data = data.replace(f, "")
|
||||
|
||||
process(limit, data)
|
||||
print()
|
9
scripts/run_celero
Executable file
9
scripts/run_celero
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
bin=$(git rev-parse --show-toplevel)/release/celero_alsk
|
||||
|
||||
benchs=$(${bin} --list|tail -n+2|tr -d ' '|tr '\n' ' ')
|
||||
|
||||
for bench in ${benchs}; do
|
||||
taskset -c 0,2,4,6 ${bin} -g "${bench}"
|
||||
done
|
Reference in New Issue
Block a user