Skip to content
Snippets Groups Projects
Commit 41dbead7 authored by pospelov's avatar pospelov
Browse files

Cleanup in Examples and Macros directories

parent cb9526bb
No related branches found
No related tags found
No related merge requests found
Showing
with 10 additions and 7998 deletions
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
namespace AppVersion { namespace AppVersion {
const std::string g_app_name = "Born Again Functional tests"; const std::string g_app_name = "Born Again Functional tests";
const std::string g_app_version_number = "v0.4"; const std::string g_app_version_number = "v0.7";
} }
#endif /* VERSION_H_ */ #endif /* VERSION_H_ */
......
This diff is collapsed.
This directory contains data samples, needed for tests. BornAgain framework usage examples.
(see also collection of functional tests located at ../Tests/FunctionalTests)
== Analysis/RootMacros == Disclaimer: For the moment directory is almost empty.
Please use C++ and Python functional tests located at ../Tests/FunctionalTests as an example.
Contains code automatically generated by ROOT analysis macros. Content:
./IsGISAXS_examples - reference files produced by IsGISAXS program for numeric comparison with BornAgain
-> TO BE MOVED ELSEWHERE (choose a directory path containing "tmp" )
== FormFactors ==
Contains images produced by App/src/TestFormFactors.cpp.
-> TO BE MOVED ELSEWHERE (choose a directory path containing "tmp" )
== IsGISAXS_examples ==
Original IsGISAXS examples 1-15:
- Parameter input files .inp
- Image output files .ima
- Scripts for plotting images and diffs
== MesoCrystals ==
??
== UsageWithPython ==
Python scripts to reproduce IsGISAXS examples 1-5 [??]
\ No newline at end of file
#!/bin/bash
# function will try to locate a header [$1] in a directory list [$*]
# Usage: ./check_header.sh fftw3.h /opt/local/include /usr/include
# Program will return name of directory if it has given header
function usage()
{
echo "check_header() -> Usage: ./check_header.sh fftw3.h /opt/local/include /usr/include"
exit 1
}
function check_header()
{
hdr=$1; shift
hdrdirs="$*"
#echo "check_header()"
#echo $hdr
#echo $hdrdirs
for i in $hdrdirs; do
#echo "checking " $i/$hdr
if test -r $i/$hdr ; then
echo $i
exit 1
fi
done
}
#infoke usage() if no arguments is supplied
[[ $# -lt 2 ]] && usage
check_header $*
#include "TStyle.h"
//
// Scattering Style at FRM-II, based on style file from ATLAS, based on a style file from BaBar
//
void BornAgainStyle() {
std::cout << "\nApplying Scattering style settings...\n" << std::endl ;
TStyle *scattStyle = new TStyle("Scattering","Scattering style");
// use plain black on white colors
Int_t icol=0; // WHITE
scattStyle->SetFrameBorderMode(icol);
scattStyle->SetFrameFillColor(icol);
scattStyle->SetCanvasBorderMode(icol);
scattStyle->SetCanvasColor(icol);
scattStyle->SetPadBorderMode(icol);
scattStyle->SetPadColor(icol);
scattStyle->SetStatColor(icol);
//scattStyle->SetFillColor(icol); // don't use: white fill color floa *all* objects
// set the paper & margin sizes
scattStyle->SetPaperSize(20,26);
scattStyle->SetPadTopMargin(0.05);
scattStyle->SetPadRightMargin(0.05);
scattStyle->SetPadBottomMargin(0.16);
scattStyle->SetPadLeftMargin(0.16);
// use large fonts
//Int_t font=72; // Helvetica italics
Int_t font=42; // Helvetica
Double_t tsize=0.05;
scattStyle->SetTextFont(font);
scattStyle->SetTextSize(tsize);
scattStyle->SetLabelFont(font,"x");
scattStyle->SetTitleFont(font,"x");
scattStyle->SetLabelFont(font,"y");
scattStyle->SetTitleFont(font,"y");
scattStyle->SetLabelFont(font,"z");
scattStyle->SetTitleFont(font,"z");
scattStyle->SetLabelSize(tsize,"x");
scattStyle->SetTitleSize(tsize,"x");
scattStyle->SetLabelSize(tsize,"y");
scattStyle->SetTitleSize(tsize,"y");
scattStyle->SetLabelSize(tsize,"z");
scattStyle->SetTitleSize(tsize,"z");
// use bold lines and markers
scattStyle->SetMarkerStyle(20);
scattStyle->SetMarkerSize(1.2);
scattStyle->SetHistLineWidth(2.);
scattStyle->SetLineStyleString(2,"[12 12]"); // postscript dashes
// get rid of X error bars and y error bar caps
//scattStyle->SetErrorX(0.001);
// do not display any of the standard histogram decorations
scattStyle->SetOptTitle(0);
//scattStyle->SetOptStat(1111);
scattStyle->SetOptStat(1);
//scattStyle->SetOptFit(1111);
scattStyle->SetOptFit(0);
// put tick marks on top and RHS of plots
scattStyle->SetPadTickX(1);
scattStyle->SetPadTickY(1);
// reset plain style
//gROOT->SetStyle("Plain");
gROOT->SetStyle("Scattering");
gROOT->ForceStyle();
}
<?xml version="1.0" standalone="no"?>
<svg width="567" height="544" viewBox="0 0 567 544" xmlns="http://www.w3.org/2000/svg">
<title>
gisasfw_loc.svg
</title>
<desc>
Creator: ROOT Version 5.34/00
CreationDate: Mon Aug 6 21:39:24 2012</desc>
<defs>
</defs>
<rect x="0" y="0" width="567" height="544" fill="white"/>
<rect x="57" y="54" width="453" height="425" fill="white"/>
<rect x="57" y="54" width="453" height="425" fill="none" stroke="black"/>
<path d="M57,479h 453" fill="none" stroke="black"/>
<path d="M93,54v 425" fill="none" stroke="black" stroke-dasharray=" 1, 2"/>
<path d="M137,54v 425" fill="none" stroke="black" stroke-dasharray=" 1, 2"/>
<path d="M181,54v 425" fill="none" stroke="black" stroke-dasharray=" 1, 2"/>
<path d="M225,54v 425" fill="none" stroke="black" stroke-dasharray=" 1, 2"/>
<path d="M268,54v 425" fill="none" stroke="black" stroke-dasharray=" 1, 2"/>
<path d="M312,54v 425" fill="none" stroke="black" stroke-dasharray=" 1, 2"/>
<path d="M356,54v 425" fill="none" stroke="black" stroke-dasharray=" 1, 2"/>
<path d="M400,54v 425" fill="none" stroke="black" stroke-dasharray=" 1, 2"/>
<path d="M444,54v 425" fill="none" stroke="black" stroke-dasharray=" 1, 2"/>
<path d="M487,54v 425" fill="none" stroke="black" stroke-dasharray=" 1, 2"/>
<path d="M93,54v 425" fill="none" stroke="black" stroke-dasharray=" 1, 2"/>
<path d="M487,54v 425" fill="none" stroke="black" stroke-dasharray=" 1, 2"/>
<path d="M57,479v -425" fill="none" stroke="black"/>
<path d="M510,479h -453" fill="none" stroke="black" stroke-dasharray=" 1, 2"/>
<path d="M510,402h -453" fill="none" stroke="black" stroke-dasharray=" 1, 2"/>
<path d="M510,326h -453" fill="none" stroke="black" stroke-dasharray=" 1, 2"/>
<path d="M510,250h -453" fill="none" stroke="black" stroke-dasharray=" 1, 2"/>
<path d="M510,174h -453" fill="none" stroke="black" stroke-dasharray=" 1, 2"/>
<path d="M510,97h -453" fill="none" stroke="black" stroke-dasharray=" 1, 2"/>
<path d="M510,97h -453" fill="none" stroke="black" stroke-dasharray=" 1, 2"/>
<path d="M57,479h 453" fill="none" stroke="black"/>
<path d="M93,466v 13" fill="none" stroke="black"/>
<path d="M115,472v 7" fill="none" stroke="black"/>
<path d="M137,466v 13" fill="none" stroke="black"/>
<path d="M159,472v 7" fill="none" stroke="black"/>
<path d="M181,466v 13" fill="none" stroke="black"/>
<path d="M203,472v 7" fill="none" stroke="black"/>
<path d="M225,466v 13" fill="none" stroke="black"/>
<path d="M247,472v 7" fill="none" stroke="black"/>
<path d="M268,466v 13" fill="none" stroke="black"/>
<path d="M290,472v 7" fill="none" stroke="black"/>
<path d="M312,466v 13" fill="none" stroke="black"/>
<path d="M334,472v 7" fill="none" stroke="black"/>
<path d="M356,466v 13" fill="none" stroke="black"/>
<path d="M378,472v 7" fill="none" stroke="black"/>
<path d="M400,466v 13" fill="none" stroke="black"/>
<path d="M422,472v 7" fill="none" stroke="black"/>
<path d="M444,466v 13" fill="none" stroke="black"/>
<path d="M466,472v 7" fill="none" stroke="black"/>
<path d="M487,466v 13" fill="none" stroke="black"/>
<path d="M93,466v 13" fill="none" stroke="black"/>
<path d="M71,472v 7" fill="none" stroke="black"/>
<path d="M487,466v 13" fill="none" stroke="black"/>
<path d="M509,472v 7" fill="none" stroke="black"/>
<text x="74" y="505" fill="black" font-size="15" font-family="Helvetica">
08/04
</text>
<text x="118" y="505" fill="black" font-size="15" font-family="Helvetica">
22/04
</text>
<text x="162" y="505" fill="black" font-size="15" font-family="Helvetica">
06/05
</text>
<text x="205" y="505" fill="black" font-size="15" font-family="Helvetica">
20/05
</text>
<text x="249" y="505" fill="black" font-size="15" font-family="Helvetica">
03/06
</text>
<text x="293" y="505" fill="black" font-size="15" font-family="Helvetica">
17/06
</text>
<text x="337" y="505" fill="black" font-size="15" font-family="Helvetica">
01/07
</text>
<text x="380" y="505" fill="black" font-size="15" font-family="Helvetica">
15/07
</text>
<text x="424" y="505" fill="black" font-size="15" font-family="Helvetica">
29/07
</text>
<text x="468" y="505" fill="black" font-size="15" font-family="Helvetica">
12/08
</text>
<path d="M57,479v -425" fill="none" stroke="black"/>
<path d="M70,479h -13" fill="none" stroke="black"/>
<path d="M63,463h -6" fill="none" stroke="black"/>
<path d="M63,448h -6" fill="none" stroke="black"/>
<path d="M63,433h -6" fill="none" stroke="black"/>
<path d="M63,418h -6" fill="none" stroke="black"/>
<path d="M70,402h -13" fill="none" stroke="black"/>
<path d="M63,387h -6" fill="none" stroke="black"/>
<path d="M63,372h -6" fill="none" stroke="black"/>
<path d="M63,357h -6" fill="none" stroke="black"/>
<path d="M63,341h -6" fill="none" stroke="black"/>
<path d="M70,326h -13" fill="none" stroke="black"/>
<path d="M63,311h -6" fill="none" stroke="black"/>
<path d="M63,296h -6" fill="none" stroke="black"/>
<path d="M63,280h -6" fill="none" stroke="black"/>
<path d="M63,265h -6" fill="none" stroke="black"/>
<path d="M70,250h -13" fill="none" stroke="black"/>
<path d="M63,235h -6" fill="none" stroke="black"/>
<path d="M63,219h -6" fill="none" stroke="black"/>
<path d="M63,204h -6" fill="none" stroke="black"/>
<path d="M63,189h -6" fill="none" stroke="black"/>
<path d="M70,174h -13" fill="none" stroke="black"/>
<path d="M63,158h -6" fill="none" stroke="black"/>
<path d="M63,143h -6" fill="none" stroke="black"/>
<path d="M63,128h -6" fill="none" stroke="black"/>
<path d="M63,113h -6" fill="none" stroke="black"/>
<path d="M70,97h -13" fill="none" stroke="black"/>
<path d="M70,97h -13" fill="none" stroke="black"/>
<path d="M63,82h -6" fill="none" stroke="black"/>
<path d="M63,67h -6" fill="none" stroke="black"/>
<text x="44" y="485" fill="black" font-size="17" font-family="Helvetica">
0
</text>
<text x="13" y="409" fill="black" font-size="17" font-family="Helvetica">
5000
</text>
<text x="4" y="332" fill="black" font-size="17" font-family="Helvetica">
10000
</text>
<text x="4" y="256" fill="black" font-size="17" font-family="Helvetica">
15000
</text>
<text x="4" y="180" fill="black" font-size="17" font-family="Helvetica">
20000
</text>
<text x="4" y="104" fill="black" font-size="17" font-family="Helvetica">
25000
</text>
<text x="172" y="27" fill="black" font-size="23" font-family="Helvetica">
Lines of code vs time
</text>
<path d="M79,479v -5h 6l 1, -3v -1l 15, -5l 3, -1l 3, -1v -1l 1, -2h 2l 1, -1h 9l 3, -2l 6, -3v -6l 3, -4h 1v -2l 9, -4l 2, -1h 1v -1l 27, -7l 3, -10h 1v -8l 10, -5l 3, -4l 2, -2l 4, -2v -1l 2, -6h 10l 3, 2l 1, -1l 2, -1h 1l 21, -5v -1l 1, -1h 3l 2,
-1l 45, -21l 9, 6v 1l 3, -1v -13h 3v 13l 16, -7l 3, -6l 3, -9v 1v -3h 3l 12, -9l 4, -5v -11l 2, 1l 1, 1v -7l 2, -3h 1l 3, -5v -7h 9l 1, -4l 6, -4l 7, -3h 8l 1, -3h 2l 1, -1v -5l 1, -1h 1v -1h 1l 3, -1l 4, -16h 1l 10, -10l 4, -44l 2, -5l 1, -6v -3l
3, -5l 12, -35l 1, -7l 3, 2l 16, -5v -1l 2, -1v -14l 1, -18v -1l 3, -1h 3l 2, -8h 1l 6, -1l 3, -1l 1, -3" fill="none" stroke="#0000ff" stroke-width="2"/>
<text x="172" y="27" fill="black" font-size="23" font-family="Helvetica">
Lines of code vs time
</text></svg>
#!/usr/bin/env python
# return current number of lines of code ('loc') in GISASFW projects
#
# should be executed either from parent directory
# "python Macros/GitUtils/git_loc_current.py"
# or from local one
# "python git_loc_current.py ../.."
from os import popen, system
import os
import getopt
from sys import argv,stderr,stdout
#from subprocess import Popen, PIPE, STDOUT
contains = [".py",".h",".cpp", ".pro" ]
notcontains = ["ThirdParty", "Doc"]
projects= {"App" : 0, "Core" : 0, "PythonAPI" : 0, "Geometry" : 0}
# command line options: path to main git directory
opts, args = getopt.getopt(argv[1:],None)
extfolder = False
if len(args) == 1:
extfolder = True
targetfolder = args[0]
prevfolder = os.getcwd()
if extfolder:
os.chdir(targetfolder)
# loop over files in git repository
nTotalLines=0;
for x in popen("git ls-files"):
# check if file name contains required patterns
x_in_contains=False
for c in contains:
if c in x:
x_in_contains=True
# check if file contains non-desired patterns
x_in_notcontains=False
for c in notcontains:
if c in x:
x_in_notcontains=True
# check if file contains desired patterns and doesn't contain non-desired
if x_in_contains and not x_in_notcontains:
print x.strip()
p = popen("wc -l "+x)
nl = p.readline().split()[0]
p.close()
# total number of lines in project
nTotalLines += int(nl)
# number of lines corresponding to additional patterns
for p in projects:
if p in x:
projects[p]+=int(nl)
# output of results
print "---"
print "Total number of lines of code in GISASFW:", nTotalLines
print "Number of lines in sub projects", projects
os.chdir(prevfolder)
#!/usr/bin/env python
# calculate number of lines of code in GISASFW project as a function of time
#
# should be executed either from parent directory
# "python Macros/GitUtils/git_loc_history.py"
# or from local one
# "python git_loc_history ../.."
#
# based on 'git-loc' from from https://github.com/ITikhonov/git-loc
#
# ROOT graphics added
# see http://root.cern.ch/drupal/content/how-use-use-python-pyroot-interpreter
import re
from email.utils import parsedate
from time import mktime
from datetime import datetime
from os import popen
import os
from sys import argv,stderr,stdout
import getopt
from array import array
opts, args = getopt.getopt(argv[1:],None)
extfolder = False
if len(args) == 1:
extfolder = True
targetfolder = args[0]
fc=0
locs=0
adds=None
cmt=None
history=[]
def pop():
if adds is not None:
pstr="%s %8u %5s %5s %7s %s \t%s"%(d,locs,'+'+str(adds),'-'+str(dels),hsh,who,cmt.strip())
#if needsvg: stderr.write(pstr+'\n')
#else: print(pstr)
print pstr
history.append((d,locs,adds,dels,hsh,who,cmt))
prevfolder = os.getcwd()
if extfolder:
os.chdir(targetfolder)
# parsing output of git log
wrong_ppp_file=False
wrong_mmm_file=False
for x in popen('git log develop --reverse -p'):
if x.startswith('commit'):
pop()
hsh=x[7:14];
if x.startswith('Author'):
who=x.replace("Author: ",'').replace('\n','');
who=re.sub(">.*","",who);
who=re.sub(".*<","",who);
if x.startswith('Date'):
fc=1
d=datetime(*parsedate(x[5:])[:7])
t=mktime(parsedate(x[5:]))
adds=0
dels=0
if fc==2:
cmt=x[:-1]
fc=0
if fc==1:
if len(x)==1: fc=2
if x.startswith('+++'):
if (".h" in x or ".cpp" in x or ".py" in x or ".pro" in x) and not "ThirdParty" in x:
wrong_ppp_file=False
else:
wrong_ppp_file=True
if x.startswith('---'):
if (".h" in x or ".cpp" in x or ".py" in x or ".pro" in x) and not "ThirdParty" in x:
wrong_mmm_file=False
else:
wrong_mmm_file=True
if x.startswith('+') and not x.startswith('+++'):
if not wrong_ppp_file:
adds+=1
locs+=1
if x.startswith('-') and not x.startswith('---'):
if not wrong_mmm_file:
dels+=1
locs-=1
pop()
os.chdir(prevfolder)
# --------------------------------------------------------
# making ROOT plot - number of lines of code .vs. time
# --------------------------------------------------------
from ROOT import TDatime, gStyle, TCanvas, TGraph, gROOT, gPad, TLatex
#gROOT.Reset()
# beginning of coding (first commit) to set beginning of time x-scale
c=history[0]
td=TDatime(c[0].year, c[0].month, c[0].day, c[0].hour, c[0].minute, c[0].second)
time_offset = int(td.Convert()) - 7*24.*3600 # one week before first commit
x, y = array( 'd' ), array( 'd' )
# loop over commits
for c in history:
td=TDatime(c[0].year, c[0].month, c[0].day, c[0].hour, c[0].minute, c[0].second)
x.append(td.Convert() - time_offset)
y.append(c[1]) # number of lines of code
# preparing graph
gr = TGraph(len(history), x, y);
gr.SetLineColor( 4 )
gr.SetLineWidth( 2 )
gStyle.SetTitleSize(0.035)
gr.SetTitle( " number of lines of code vs time " )
gr.GetXaxis().SetLabelOffset( 0.025 )
gr.GetXaxis().SetTimeDisplay(1)
#gr.GetXaxis().SetTimeFormat("#splitline{%d %m %y}{%H:%M}")
gr.GetXaxis().SetTimeFormat("%d/%m")
gr.GetXaxis().SetLabelSize(0.03)
gr.GetXaxis().SetNdivisions(512)
gr.GetXaxis().SetTimeOffset(time_offset)
#preparing canvas
c1 = TCanvas( 'gisasfw_loc', 'Number of lines of code in GISASFW project', 600, 600)
c1.SetGrid()
gPad.SetBottomMargin(0.12)
# drawing
gr.Draw("al")
#txt=TLatex()
#txt.SetNDC()
#txt.SetTextSize(0.025)
#txt.DrawLatex(0.2,0.95,"Lines of code vs time")
c1.Modified()
c1.Print("gisasfw_loc.png")
# wait for input to keep the GUI (which lives on a ROOT event dispatcher) alive
if __name__ == '__main__':
rep = ''
while not rep in [ 'q', 'Q' ]:
rep = raw_input( 'enter "q" to quit: ' )
if 1 < len(rep):
rep = rep[0]
#!/usr/bin/env python
# calculate number of lines of code in GISASFW project as a function of time
#
# should be executed either from parent directory
# "python Macros/GitUtils/git_loc_history.py"
# or from local one
# "python git_loc_history ../.."
#
# based on 'git-loc' from from https://github.com/ITikhonov/git-loc
#
# ROOT graphics added
# see http://root.cern.ch/drupal/content/how-use-use-python-pyroot-interpreter
import re
from email.utils import parsedate
from time import mktime
from datetime import datetime
from os import popen
import os
from sys import argv,stderr,stdout
import getopt
from array import array
opts, args = getopt.getopt(argv[1:],None)
extfolder = False
if len(args) == 1:
extfolder = True
targetfolder = args[0]
fc=0
locs=0
locs_type=[0,0,0,0,0,0,0,0,0]
# 0 1 2 3 4 5 6 7 8
descr=["Core","Functional Tests","Unit Tests","*.py","macros","GUI", "PyAPI","Third","Undef"]
adds=None
cmt=None
prev_time = datetime(2000,1,1)
history=[]
def pop():
if adds is not None:
pstr="%s %8u %5s %5s %7s %s \t%s"%(d,locs,'+'+str(adds),'-'+str(dels),hsh,who,cmt.strip())
print pstr
atmp = []
for x in locs_type:
atmp.append(x)
history.append((d,locs,atmp,adds,dels,hsh,who,cmt))
def filetype(x):
file_type=8
if "/Core/Algorithms/" in x and (".h" in x or ".cpp" in x):
file_type = 0
elif "/Core/FormFactors/" in x and (".h" in x or ".cpp" in x):
file_type = 0
elif "/Core/Geometry/" in x and (".h" in x or ".cpp" in x):
file_type = 0
elif "/Core/Samples/" in x and (".h" in x or ".cpp" in x):
file_type = 0
elif "/Core/Tools/" in x and (".h" in x or ".cpp" in x):
file_type = 0
if "/Core/Fitting/" in x and (".h" in x or ".cpp" in x):
file_type = 0
elif "/Core/inc/" in x and (".h" in x):
file_type = 0
elif "/Core/src/" in x and (".cpp" in x):
file_type = 0
elif "/App/" in x and (".h" in x or ".cpp" in x):
file_type = 1
elif "/Tests/FunctionalTests/TestCore" in x and (".h" in x or ".cpp" in x):
file_type = 1
elif "/UnitTests/" in x and (".h" in x or ".cpp" in x):
file_type = 2
elif "/Tests/UnitTests/TestCore/" in x and (".h" in x or ".cpp" in x):
file_type = 2
elif ".py" in x and not "ThirdParty" in x and not "Core/PythonAPI" in x:
print x
file_type = 3
elif ".C" in x or ".pro" in x or ".pri" in x or "*.sh" in x and not "ThirdParty" in x and not "pro.user" in x:
file_type = 4
elif "/GUI/coregui" in x and (".h" in x or ".cpp" in x) and not "widgetbox" in x:
file_type = 5
elif "/AppGUI/coregui" in x and (".h" in x or ".cpp" in x):
file_type = 5
elif "/BASuite" in x and (".h" in x or ".cpp" in x):
file_type = 5
elif "Core/PythonAPI" in x and (".h" in x or ".cpp" in x):
file_type = 6
elif "ThirdParty" in x:
file_type = 7
return file_type
prevfolder = os.getcwd()
if extfolder:
os.chdir(targetfolder)
# parsing output of git log
file_type_ppp = 8
file_type_mmm = 8
for x in popen('git log develop --reverse -p'):
if x.startswith('commit'):
pop()
hsh=x[7:14];
if x.startswith('Author'):
who=x.replace("Author: ",'').replace('\n','');
who=re.sub(">.*","",who);
who=re.sub(".*<","",who);
if x.startswith('Date'):
fc=1
d=datetime(*parsedate(x[5:])[:7])
t=mktime(parsedate(x[5:]))
adds=0
dels=0
if fc==2:
cmt=x[:-1]
fc=0
if fc==1:
if len(x)==1: fc=2
if x.startswith('+++'):
file_type_ppp = filetype(x)
if x.startswith('---'):
file_type_mmm = filetype(x)
if x.startswith('+') and not x.startswith('+++'):
locs_type[file_type_ppp] += 1
if file_type_ppp <6:
adds+=1
locs+=1
if x.startswith('-') and not x.startswith('---'):
locs_type[file_type_mmm] -= 1
if file_type_mmm <6:
dels+=1
locs-=1
pop()
os.chdir(prevfolder)
# --------------------------------------------------------
# making ROOT plot - number of lines of code .vs. time
# --------------------------------------------------------
from ROOT import *
# beginning of coding (first commit) to set beginning of time x-scale
c=history[0]
td=TDatime(c[0].year, c[0].month, c[0].day, c[0].hour, c[0].minute, c[0].second)
time_offset = int(td.Convert()) - 7*24.*3600 # one week before first commit
# loop over commits
x, y, xbins = array( 'd' ), array( 'd' ), array( 'd' )
for c in history:
td=TDatime(c[0].year, c[0].month, c[0].day, c[0].hour, c[0].minute, c[0].second)
x.append(td.Convert() - time_offset)
xbins.append(td.Convert() - time_offset)
y.append(c[1]) # number of lines of code
print c[0],c[1],"(",descr[0],c[2][0],",",descr[1],c[2][1],",",descr[2],c[2][2],",",descr[3],c[2][3],",",descr[4],c[2][4],",",descr[5],c[2][5],")"
# axis with bin edge description
xbins = sorted(xbins)
dx = x[len(x)-1] - x[len(x)-2]
xbins.append(x[len(x)-1]+dx)
xtmp = array( 'd' )
for i in range(0, len(xbins)):
xtmp.append(xbins[i])
# applying visual style
ROOT.gROOT.LoadMacro("BornAgainStyle.C");
ROOT.gROOT.ProcessLine("BornAgainStyle()")
# creating histograms
nhistograms=7
a_histograms = []
hstack = THStack("hstack","Number of Lines of Code")
hstack.SetTitle("");
#a_colors=[kAzure+1, kCyan+1, kRed+1, kOrange+1, kMagenta+1, kGreen+1, kGray]
#a_colors=[kBlue+1, kOrange, kRed+1, kOrange, kMagenta, kBlue-9, kGreen]
a_colors=[kAzure+1, kOrange, kRed, kGreen, kYellow-7, kAzure, kGray+1]
legend = TLegend(0.17,0.55,0.42,0.90)
legend.SetBorderSize(1);
legend.SetFillStyle(1);
for i_hist in range(0,nhistograms):
hist = TH1D(descr[i_hist],descr[i_hist],len(xtmp)-1,xtmp)
hist.GetXaxis().SetTimeDisplay(1)
hist.GetXaxis().SetTimeFormat("%d/%m")
hist.GetYaxis().SetLabelSize(0.030)
hist.GetXaxis().SetLabelSize(0.035)
hist.GetXaxis().SetNdivisions(512)
hist.GetXaxis().SetTimeOffset(time_offset)
hist.SetLineColor(a_colors[i_hist])
hist.SetFillColor(a_colors[i_hist])
hstack.Add(hist,"][")
a_histograms.append(hist)
# adding histograms to legend in right order
for i_hist in range(nhistograms-1,-1,-1):
legend.AddEntry(a_histograms[i_hist],descr[i_hist],"f")
# filling histograms
for c in history:
td=TDatime(c[0].year, c[0].month, c[0].day, c[0].hour, c[0].minute, c[0].second)
xx = td.Convert() - time_offset
for i_hist in range(0,nhistograms):
yy = c[2][i_hist]
a_histograms[i_hist].Fill(xx,yy)
#preparing canvas
c1 = TCanvas( 'gisasfw_loc', 'Number of lines of code in GISASFW project', 600, 600)
c1.cd()
gPad.SetGrid()
gPad.SetBottomMargin(0.12)
gPad.SetLeftMargin(0.11)
# drawing
hstack.Draw()
hstack.GetXaxis().SetTimeDisplay(1)
#hstack.GetXaxis().SetTimeFormat("%d/%m")
hstack.GetXaxis().SetTimeFormat("#splitline{%d/%m}{%Y}")
hstack.GetXaxis().SetLabelSize(0.03)
hstack.GetYaxis().SetLabelSize(0.035)
hstack.GetXaxis().SetLabelOffset(0.02)
hstack.GetXaxis().SetNdivisions(512)
hstack.GetXaxis().SetTimeOffset(time_offset)
legend.Draw()
c1.Modified()
gPad.RedrawAxis()
gPad.RedrawAxis("G")
c1.Modified()
c1.Update()
c1.Print("gisasfw_loc.png")
# wait for input to keep the GUI (which lives on a ROOT event dispatcher) alive
if __name__ == '__main__':
rep = ''
while not rep in [ 'q', 'Q' ]:
rep = raw_input( 'enter "q" to quit: ' )
if 1 < len(rep):
rep = rep[0]
Directory contains different scripts for running code profiling utilities. Directory contains different scripts for running code profiling utilities.
There are two ways of code profiling: using valgrind and using gperftool
---------------------------------------------------------- ----------------------------------------------------------
Profiling with valgrind Profiling with valgrind
---------------------------------------------------------- ----------------------------------------------------------
1) Compile GISASFW as usuall and simply run 1) Compile BornAgain as usuall and simply run
./run_valgrind.sh ./run_valgrind.sh
...@@ -16,7 +17,7 @@ Profiling with gperftool ...@@ -16,7 +17,7 @@ Profiling with gperftool
download code from http://code.google.com/p/gperftools/ download code from http://code.google.com/p/gperftools/
./configure --prefix=/opt/local; make; make install ./configure --prefix=/opt/local; make; make install
2) GISASFW should be compiled with GPERFTOOLS in config 2) BornAgain should be compiled with GPERFTOOLS in config
make distclean make distclean
qmake CONFIG+=GPERFTOOLS qmake CONFIG+=GPERFTOOLS
make make
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment