-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path00-introduction.html
71 lines (71 loc) · 4.52 KB
/
00-introduction.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="generator" content="pandoc">
<title>Software Carpentry: Testing/Debugging/Profiling</title>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="css/bootstrap/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="css/bootstrap/bootstrap-theme.css" />
<link rel="stylesheet" type="text/css" href="css/swc.css" />
<link rel="alternate" type="application/rss+xml" title="Software Carpentry Blog" href="http://software-carpentry.org/feed.xml"/>
<meta charset="UTF-8" />
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body class="lesson">
<div class="container card">
<div class="banner">
<a href="http://software-carpentry.org" title="Software Carpentry">
<img alt="Software Carpentry banner" src="img/software-carpentry-banner.png" />
</a>
</div>
<article>
<div class="row">
<div class="col-md-10 col-md-offset-1">
<a href="index.html"><h1 class="title">Testing/Debugging/Profiling</h1></a>
<h2 class="subtitle">Introduction</h2>
<section class="objectives panel panel-warning">
<div class="panel-heading">
<h2 id="learning-objectives"><span class="glyphicon glyphicon-certificate"></span>Learning Objectives</h2>
</div>
<div class="panel-body">
<ul>
<li>Know the meaning of testing, debugging, profiling</li>
<li>Understand their place in the scientific workflow</li>
</ul>
</div>
</section>
<p>This lesson serves as a brief introduction to the following topics (each well worthy of a lesson of their own):</p>
<ul>
<li><strong>testing</strong>: the process of making sure that a program does what it is suppposed to do. Achieved by 1) writing code (a <em>test</em>) that runs a part of the main code and compares the result to the expected result and 2) automatizing the process of running those tests.</li>
<li><strong>debugging</strong>: the process of finding the source of errors in the code, in particular with the help of a <em>symbolic debugger</em>.</li>
<li><strong>profiling</strong>: the first step of optimizing the execution speed of a program by measuring its runtime. These measures can be taken on various levels, e.g.: the complete runtime of the full code or a part of it; the runtime for each function in the code; the runtime of each line of code in a function.</li>
</ul>
<p>A simplified process of code development, involving all the three elements can look like the following:</p>
<ol style="list-style-type: decimal">
<li>Write code that solves a specific problem</li>
<li>Write <em>tests</em> for that code, showing that it actually solves the problem (taking special care of corner and edge cases)</li>
<li>When tests fail, <em>debug</em> the code to find the root cause.</li>
<li>If the code runs too slowly for the purpose at hand, <em>profile</em> it to find out where the time is spent and optimize the code (using the test suite to verify that everything is still working correctly)</li>
</ol>
<p>Some developers recommend to switch step 1 and 2 around, i.e. to actually write the tests <em>before</em> the code (therefore starting with a test suite full of failing tests). This is called <a href="https://en.wikipedia.org/wiki/Test-driven_development">test-driven development</a> and adopting it at least partially is certainly a good idea: whenever a bug occurs, writing first a test that reliably fails can dramatically help in the later stages of debugging it.</p>
</div>
</div>
</article>
<div class="footer">
<a class="label swc-blue-bg" href="http://software-carpentry.org">Software Carpentry</a>
<a class="label swc-blue-bg" href="https://github.com/paris-swc/python-testing-debugging-profiling">Source</a>
<a class="label swc-blue-bg" href="mailto:[email protected]">Contact</a>
<a class="label swc-blue-bg" href="LICENSE.html">License</a>
</div>
</div>
<!-- Javascript placed at the end of the document so the pages load faster -->
<script src="http://software-carpentry.org/v5/js/jquery-1.9.1.min.js"></script>
<script src="css/bootstrap/bootstrap-js/bootstrap.js"></script>
<script src='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
</body>
</html>