Popular recipes by Thomas Lehmann http://code.activestate.com/recipes/users/4174477/2014-12-05T04:39:51-08:00ActiveState Code RecipesObjectify of a XML node (Python) 2014-12-05T04:39:51-08:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/578976-objectify-of-a-xml-node/ <p style="color: grey"> Python recipe 578976 by <a href="/recipes/users/4174477/">Thomas Lehmann</a> (<a href="/recipes/tags/objectify/">objectify</a>, <a href="/recipes/tags/xml/">xml</a>). </p> <p>The script allows you to convert a XML node into an object instance that has the XML node attributes as fields with the given values. The values are converted (when possible):</p> <ul> <li>from string to int</li> <li>from string to float</li> <li>or remain as string</li> </ul> <p>You also initially can provide a dictionary of (key,value) to ensure existence of certain fields which might not be provided by the XML node but on the other hand those values might be overwritten by the XML node.</p> <p>Please have a look at the docstring for the example ...</p> More strict unittests using a validator (Python) 2014-03-01T12:37:47-08:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/578793-more-strict-unittests-using-a-validator/ <p style="color: grey"> Python recipe 578793 by <a href="/recipes/users/4174477/">Thomas Lehmann</a> (<a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/unittests/">unittests</a>, <a href="/recipes/tags/validator/">validator</a>). Revision 4. </p> <p>The main point is that <strong>there was no binding between a unit tests and the concrete class</strong>. It did happend often that you are indirectly testing a class using it also the concrete test class has missed some concrete test methods. I found this fact sometimes very irritating seeing 100% coverage.</p> <p>Therefor I now provide this class decorator where you can specify the class that will be tested. If you do not specify test methods for each method of the testable class <strong>an exception will be thrown providing a list of missed tests</strong>.</p> <p>Here some examples how it works: You implemented a</p> <ul> <li>method "__eq__", then write a "testEqual" method</li> <li>method "__init__", then write a testInit" method</li> <li>method "scalar_product", then write a testScalarProduct" method</li> <li>and so on ...</li> </ul> <p>The way to use this class decorator you can see in the doctest area (see below in the code) The only point to be aware of is that when you use the decorator you have to implement all test to get rid of the thrown execption. Of course you can implement more tests for same class.</p> <p>New in revision 4 (1st march 2014):</p> <ul> <li>Bugfix: the algorithm were not correctly detecting which methods were really overwritten forcing to implement tests for methods which were base class only.</li> <li>Bugfix: decorated classes which contain the attribute "decorated_object" can be handled properly. </li> <li><p>A new second parameter now allows you to implement several classes in same test class forcing you to include the class name in the test method:</p> <ul> <li>@ValidateTestResponsibilityFor(Square, True)</li> <li>@ValidateTestResponsibilityFor(Sin, True)</li> <li>=&gt; testSquareInit, testSquareGet, testSinInit, testSinGet, ...</li> <li>This for smaller classes to avoid too many files (at least ... you decided)</li> </ul></li> </ul> InMemoryZip class (Python) 2013-09-23T06:44:23-07:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/578667-inmemoryzip-class/ <p style="color: grey"> Python recipe 578667 by <a href="/recipes/users/4174477/">Thomas Lehmann</a> (<a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/memory/">memory</a>, <a href="/recipes/tags/path/">path</a>, <a href="/recipes/tags/zip/">zip</a>). </p> <p><strong>Why implementing this?</strong></p> <ul> <li>transfering a file or a folder (including sub folders) to another machine</li> <li>therefore zipping content to one compressed buffer</li> <li>keeping the relating ZIP in memory only but ...</li> <li>being able to save or load too</li> <li>and being able to unzip again at target destination</li> </ul> easyjson.py - parsing JSON from buffer and from file (Python) 2013-05-27T05:32:07-07:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/578529-easyjsonpy-parsing-json-from-buffer-and-from-file/ <p style="color: grey"> Python recipe 578529 by <a href="/recipes/users/4174477/">Thomas Lehmann</a> (<a href="/recipes/tags/json/">json</a>, <a href="/recipes/tags/parser/">parser</a>). Revision 4. </p> <p><strong>JSON Parser</strong>:</p> <ul> <li>Refering to <a href="http://www.json.org/" rel="nofollow">http://www.json.org/</a></li> <li>Just one simple Python file you can integrate where you want to</li> <li>No imports (very important) -> no dependencies!!!</li> <li>Should work with really older versions of Python!!!</li> </ul> <p><strong>Todo's</strong>:</p> <ul> <li>Doesn't cover full number format</li> <li>...</li> </ul> <p><strong>Done</strong></p> <ul> <li>Allows string in string (revision 2)</li> <li>Covers objects in an array (revision 2)</li> <li>Provides a mechanism to allow other dictionaries (like collections.OrderedDict) (revision 3)</li> <li>Conversion of numbers to integer or float types (revision 4)</li> </ul> Eight queen problem (Javascript) (JavaScript) 2013-03-20T19:03:44-07:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/578497-eight-queen-problem-javascript/ <p style="color: grey"> JavaScript recipe 578497 by <a href="/recipes/users/4174477/">Thomas Lehmann</a> (<a href="/recipes/tags/algorithm/">algorithm</a>, <a href="/recipes/tags/queen/">queen</a>, <a href="/recipes/tags/queens/">queens</a>). </p> <ul> <li>Adding this for my old <a href="http://code.activestate.com/recipes/577438/">recipe 577438</a> (in Python).</li> <li>Use node.js or HTML as execution (see comments in "log" function)</li> </ul> Puzzle: Four cubes with different colors on their sides (Python) 2013-02-11T10:32:26-08:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/578454-puzzle-four-cubes-with-different-colors-on-their-s/ <p style="color: grey"> Python recipe 578454 by <a href="/recipes/users/4174477/">Thomas Lehmann</a> (<a href="/recipes/tags/colors/">colors</a>, <a href="/recipes/tags/cube/">cube</a>, <a href="/recipes/tags/puzzle/">puzzle</a>). </p> <p>I have four cubes (in real) with different colors on their sides as a puzzle with the final goal to place each cube side by side that way that on each visible side (except the two ends) you can see four different colors.</p> <p>I have placed the cubes as they are (side by side) writing down the current colors (see function main). The CubesChecker class is searching for one solution. You don't see the operation on how to rotate but knowing the final state it's really easy to do it yourself then.</p> Singleton (parameter based) (Python) 2012-04-18T06:13:25-07:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/578103-singleton-parameter-based/ <p style="color: grey"> Python recipe 578103 by <a href="/recipes/users/4174477/">Thomas Lehmann</a> (<a href="/recipes/tags/parameters/">parameters</a>, <a href="/recipes/tags/singleton/">singleton</a>). Revision 3. </p> <p><strong>Why?</strong></p> <ul> <li>There are many recipes but nearly all cover the global singleton only.</li> <li>I need a singleton which can handle things in a specific context (environment).</li> </ul> <p><strong>The final singleton is a combination of following two recipes</strong>:</p> <ul> <li><a href="http://www.python.org/dev/peps/pep-0318/#examples" rel="nofollow">http://www.python.org/dev/peps/pep-0318/#examples</a></li> <li><a href="http://stackoverflow.com/a/9489387" rel="nofollow">http://stackoverflow.com/a/9489387</a></li> </ul> <p><strong>The basic advantages</strong>:</p> <ul> <li>Hiding the singleton code by a simple decorator</li> <li>Flexible, because you can define fully global singletons or parameter based singletons.</li> </ul> <p><strong>Latest changes</strong>:</p> <ul> <li>Although a function/method does not have parameters you can call it with parameters <strong>args</strong> and <strong>kwargs</strong> as you now see in the <strong>getInstance</strong> function.</li> <li>...</li> </ul> Human readable format for a given time delta (Python) 2012-04-26T10:37:10-07:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/578113-human-readable-format-for-a-given-time-delta/ <p style="color: grey"> Python recipe 578113 by <a href="/recipes/users/4174477/">Thomas Lehmann</a> (<a href="/recipes/tags/back/">back</a>, <a href="/recipes/tags/date/">date</a>, <a href="/recipes/tags/human/">human</a>, <a href="/recipes/tags/readable/">readable</a>, <a href="/recipes/tags/time/">time</a>). </p> <p><strong>What is it about?</strong></p> <ul> <li>I need to say someting like <em>1 day ago</em>, <em>5 days ago</em>, <em>2 weeks ago</em>, ...</li> <li>I can control to have it with/without milliseconds and microseconds.</li> <li>I can use it automatically with current date and time or with a provide one.</li> </ul> <p><strong>Why?</strong></p> <ul> <li>I need it for next revision of my <a href="http://code.activestate.com/recipes/578111/">recipe 578111</a>.</li> <li>I found recipes here and there but often it is always assumed that a month has 30 days and that a year has 365 days; this is not true. That's why I've left away months and years.</li> </ul> Simple linear regression (Python) 2012-05-12T13:36:55-07:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/578129-simple-linear-regression/ <p style="color: grey"> Python recipe 578129 by <a href="/recipes/users/4174477/">Thomas Lehmann</a> (<a href="/recipes/tags/decrease/">decrease</a>, <a href="/recipes/tags/increase/">increase</a>, <a href="/recipes/tags/linear/">linear</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/percental/">percental</a>, <a href="/recipes/tags/regression/">regression</a>, <a href="/recipes/tags/simple/">simple</a>). Revision 3. </p> <p><strong>What?</strong></p> <ul> <li>It's about forecasting.</li> <li>It's about calculating a linear function.</li> <li><em>Details I found</em>: <a href="http://www.faes.de/Basis/Basis-Statistik/Basis-Statistik-Korrelation-Re/basis-statistik-korrelation-re.html" rel="nofollow">http://www.faes.de/Basis/Basis-Statistik/Basis-Statistik-Korrelation-Re/basis-statistik-korrelation-re.html</a> (in german)</li> </ul> <p>Also I don't know how the formula have been created the practical part was very easy to me. I have verified one example (see code) using Open Office Calc (I've learned: you can display the formula for the trend line as well as the coefficient of correlation - great).</p> <p><strong>Why?</strong></p> <ul> <li>In <a href="http://code.activestate.com/recipes/578111/">recipe 578111</a> I'm printing out current error rate for different training sessions in mental arithmetic.</li> <li>Anyway I would like to be able to given information - approximately - about how many you have improved since you train yourself.</li> </ul> <p><strong>What has changed?</strong></p> <ul> <li><strong>Revision2</strong>: Didn't compile with Jython 2.5.3b1 because of not supported exception syntax. Now it does work without exception.</li> <li><strong>Revision3</strong>: Test data row for failure not removed.</li> </ul> Learning to calculate (mental arithmetic) (Python) 2012-05-11T03:49:48-07:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/578111-learning-to-calculate-mental-arithmetic/ <p style="color: grey"> Python recipe 578111 by <a href="/recipes/users/4174477/">Thomas Lehmann</a> (<a href="/recipes/tags/learning/">learning</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/persistence/">persistence</a>, <a href="/recipes/tags/statistic/">statistic</a>, <a href="/recipes/tags/training/">training</a>). Revision 4. </p> <p><strong>What is it about?</strong></p> <ul> <li>Learning to use the basic math operation (+, -, *,/).</li> <li>Print out of statistics to show you where you are.</li> <li>Being able to define your own training sessions.</li> <li>Sessions with number of tasks or with a time limit.</li> </ul> <p><strong>What has changed?</strong></p> <ul> <li>Revision 2: Contains now the <strong>tasks numbering</strong>.</li> <li>Revision 2: You can see overall how long you didn't a training.</li> <li>Revision 2: You also can see per kind of session how long you didn't a training.</li> <li>Revision 3: <strong>Trainings parameter as kind of policy</strong> in a separate class also used as key for statistic.</li> <li>Revision 3: <strong>New session type</strong>: timeout (as many tasks as possible until timeout exceeded)</li> <li>Revision 3: I'm also sorry to say that this revision breaks compatibility with previously stored sessions.</li> <li>Revision 4: <strong>Integer division</strong> supported.</li> </ul> Sequence Builder (Python) 2012-03-03T17:50:03-08:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/578061-sequence-builder/ <p style="color: grey"> Python recipe 578061 by <a href="/recipes/users/4174477/">Thomas Lehmann</a> (<a href="/recipes/tags/builder/">builder</a>, <a href="/recipes/tags/sequence/">sequence</a>). Revision 2. </p> <p><strong>Why?</strong></p> <ul> <li>Thinking about a sequence of odd numbers where numbers divisible by 3 are not part of it I came to a sequence starting with 5, 7, 11, 13, 17, 19, ...</li> <li>The interesting property of this sequence is that the sequence of differences between the individual elements are 2,4,2,4,2,...</li> </ul> <p><strong>How?</strong></p> <ul> <li>I'm not a math expert (unfortunately) but I could imagine that there is a quite simple formula to get this.</li> <li>However I thought that using different combinations of defined functions a script could do the favour for me.</li> </ul> <p><strong>Result?</strong></p> <ul> <li>Formula: <code>(((-1)**(x-1))+1)+2</code> -> Simplified -> <code>-1**(x-1) + 3</code> (now clear to you?)</li> <li>You have to look for the sequence [4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2]</li> </ul> <p><strong>Out of scope:</strong></p> <ul> <li>Does not check for using lambda functions only and "x" only in the lambda functions.</li> <li>The Python script does not simplify functions like changing ((x+1)+1) to x+2 - would be an interesting recipe - by the way :)</li> </ul> <p><strong>Please note</strong></p> <ul> <li>You should not add other functions than lambda.</li> <li>You should always use "x" in your formular.</li> <li>Be aware that the actual setup runs a few minutes (about 3 minutes) and you can imagine - surely - that adding further functions will definitely increase the runtime.</li> </ul> <p><strong>Side effects?</strong></p> <ul> <li>Quite funny to produce a sequence of nines with <code>(((-1)**(2*x))+2)**2</code>.</li> <li>If you apply the first binomial theorem (a+b)^2 = a^2 + 2ab + b^2 then you see why!</li> </ul> <p><strong>What I have learned from this?</strong></p> <ul> <li>The biggest nightmare I did have with the Sequence class because of not knowing how to generate unique elements of this in a set (__eq__ and __hash__ are required); and I have to ensure that the hash code is calculated once only.</li> <li>The 'combineFunctions' was interesting to me. I have never used 'inspect.getsource' before.</li> <li>A few minutes does not sound much but for developing all times with more than 30 seconds are not comfortable. There are just 325 sequences and to investigate for certain sequences you probably have to have some more formula. Maybe I would have to take another approach for that.</li> </ul> Simple Python Checker (Python) 2012-01-24T21:37:33-08:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/578023-simple-python-checker/ <p style="color: grey"> Python recipe 578023 by <a href="/recipes/users/4174477/">Thomas Lehmann</a> (<a href="/recipes/tags/analyse/">analyse</a>, <a href="/recipes/tags/analyze/">analyze</a>, <a href="/recipes/tags/checker/">checker</a>, <a href="/recipes/tags/code/">code</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/simple/">simple</a>). Revision 2. </p> <p><strong>Why this recipe?</strong>:</p> <ul> <li>pylint is great but I does not support newer python versions.</li> <li>I intended to write an own more simple parser recognizing that Python is doing the job for me and so I started to learn - a little - how to use AST.</li> </ul> <p><strong>In scope (for this recipe)</strong>:</p> <ul> <li>scanning a single python file displaying warnings and errors when breaking rules.</li> <li>easy to maintain and easy extensible.</li> <li>reporting messages in a way - when displayed in an editor - you can click on them to jump to the location for the relating message.</li> <li>Lines of code means: without blanks (later: also without comments)</li> </ul> <p><strong>Out of scope (for this recipe)</strong>:</p> <ul> <li>For the recipe the folder/path support would break my limits. This include also the possible limits for this.</li> <li>Checking for comments (SIngle line comments, block comments, checking for parameter documentation)</li> </ul> <p><strong>Future:</strong></p> <ul> <li>I'm thinking about putting this on a project base location (issue tracker, versioning, ...).</li> <li>Of course same free license.</li> <li>Providing a link here.</li> <li>Checking for comments to handle further limits (LOC/COM, COM, checking for tags vs. parameters).</li> <li>Allow to handle a path/folder with Python files (another statistic output)</li> </ul> Simple enum mechanism (Python) 2012-01-15T12:30:31-08:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/578015-simple-enum-mechanism/ <p style="color: grey"> Python recipe 578015 by <a href="/recipes/users/4174477/">Thomas Lehmann</a> (<a href="/recipes/tags/enum/">enum</a>). </p> <p><strong>Here are the basic ideas (orientation: C++)</strong>:</p> <ul> <li>You are responsible to find names for constants and this code provides a way to give values which differ from each other</li> <li>The context is to allow different enums with values starting by 0</li> <li>If you like to use constants like here: "Orientation.TOP" then place those constants in the relating class</li> <li>You still can assign your own values</li> </ul> <p><strong>About the code</strong>:</p> <ul> <li>It's not much code also it might look like (implementation + documentation + unittests)</li> <li>The __docformat__ is for epydoc. Temporarily remove the "@singleton" when trying to generate the HTML documentation (can not yet be handled by epydoc).</li> </ul> <p><strong>Example(s)</strong>: Have a look at the unittests please.</p> Simple Knowlegde Database (Python) 2012-01-05T08:58:40-08:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/577975-simple-knowlegde-database/ <p style="color: grey"> Python recipe 577975 by <a href="/recipes/users/4174477/">Thomas Lehmann</a> (<a href="/recipes/tags/antagonisms/">antagonisms</a>, <a href="/recipes/tags/database/">database</a>, <a href="/recipes/tags/knowledge/">knowledge</a>, <a href="/recipes/tags/opposites/">opposites</a>, <a href="/recipes/tags/relationships/">relationships</a>). Revision 2. </p> <p><strong>What's the idea?</strong></p> <ul> <li>The idea is to be able to ask more successful questions than data provided.</li> <li>To have a kind of simple database</li> </ul> <p><strong>How is this done?</strong></p> <ul> <li>A releationship is always though as a from of older/younger or bigger/smaller. You have to define those opposite meanings by calling 'defineAntagonism'</li> <li>After this you can define a relationship by calling 'defineRelationship' using one of the opposite meanings and two ... I say names (can be persons or objects)</li> <li>When you define that somebody/someting is bigger than somebody/something else then you implicitly provide two information (bigger &lt;-> smaller)</li> <li>Also when defining - more commonly explained - that A &gt; B and B &gt; C then also A &gt; C and C &lt; A. </li> <li>That's the main logic implemented by this python code.</li> </ul> <p><strong>Special notes</strong></p> <ul> <li>We have to avoid inconsistent data; when it is defined that A &gt; B then you are not allowed to say that B &gt; A.</li> <li>We have to sort relations because they build up - I name it like this - a dependency chain. When a query checks for A &gt; C but A &gt; B and B &gt; C is defined only we need an order for searching.</li> </ul> Lattice Multiplication (Python) 2011-07-07T07:07:59-07:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/577782-lattice-multiplication/ <p style="color: grey"> Python recipe 577782 by <a href="/recipes/users/4174477/">Thomas Lehmann</a> (<a href="/recipes/tags/lattice/">lattice</a>, <a href="/recipes/tags/multiplication/">multiplication</a>). </p> <p>The documentation in the function explains the algorithm but there are additional pages which provide additional visual help:</p> <ul> <li><a href="http://mathforum.org/library/drmath/view/52468.html" rel="nofollow">http://mathforum.org/library/drmath/view/52468.html</a></li> <li><a href="http://en.wikipedia.org/wiki/Multiplication_algorithm" rel="nofollow">http://en.wikipedia.org/wiki/Multiplication_algorithm</a></li> </ul> <p>The function can handle a string as well as a sequence of digits. The test function is just to have a basic verification.</p> Power Of Two (Python) 2010-11-28T16:05:19-08:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/577475-power-of-two/ <p style="color: grey"> Python recipe 577475 by <a href="/recipes/users/4174477/">Thomas Lehmann</a> (<a href="/recipes/tags/power_of_two/">power_of_two</a>). </p> <ul> <li>It's a simple algorithm doing nearly the same what you can do when calculating a multiplication on a piece on paper.</li> <li>In python you don't need this. You simply say 2**n and you have it; so see it as prototyping for a final C/C++ program where you are limited by the given datatypes ... as long you don't write a 'BigNumber' class.</li> </ul> Eight queen problem (Python) 2013-05-10T03:44:56-07:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/577438-eight-queen-problem/ <p style="color: grey"> Python recipe 577438 by <a href="/recipes/users/4174477/">Thomas Lehmann</a> (<a href="/recipes/tags/algorithms/">algorithms</a>, <a href="/recipes/tags/queen/">queen</a>). Revision 5. </p> <p><strong>Task</strong>:</p> <ul> <li>Think of a chess field 8x8.</li> <li>Place 8 queens in a way that no one threaten another one.</li> </ul> <p><strong>Intention</strong>:</p> <ul> <li>Writing an algorithm to provide all solutions</li> <li>Adjusting the algorithm in a way that it can handle chess fields by other sizes n x n.</li> </ul> <p><strong>Changes</strong>:</p> <ul> <li><strong>Revision 5</strong>: <ul> <li>can run providing "n" via command line parameter and </li> <li>run half of board adding the other solutions by mirroring (12x12 takes 4 seconds instead of 8 on my slow notebook)</li> </ul></li> <li>...</li> </ul> <p><strong>Other languages</strong>:</p> <ul> <li>My <a href="http://code.activestate.com/recipes/578497/">recipe 578497</a> for JavaScript</li> <li>...</li> </ul> Some prime generation algorithms. (Python) 2010-08-06T11:20:34-07:00Thomas Lehmannhttp://code.activestate.com/recipes/users/4174477/http://code.activestate.com/recipes/577329-some-prime-generation-algorithms/ <p style="color: grey"> Python recipe 577329 by <a href="/recipes/users/4174477/">Thomas Lehmann</a> (<a href="/recipes/tags/generation/">generation</a>, <a href="/recipes/tags/is_prime/">is_prime</a>, <a href="/recipes/tags/prime/">prime</a>, <a href="/recipes/tags/primes/">primes</a>). Revision 4. </p> <p>Basic idea was to see the difference between different prime algorithms in time. Also they are not perfect the output shows that really higher numbers let grow the difference why I have separated this into functions to make it visible. I add this here because I have been missing this very often when I have been searching for algorithms.</p> <ul> <li>The 'is_prime' is a well known way of checkin for a number being prime or not.</li> <li>The sieve of Erastothenes is simply to strike out multiples of a given value; the primes will remain.</li> <li>the function 'profile' is a decorator for functions measuring the execution time</li> <li>Some information are in the comments of the code</li> </ul>