sum_()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
cc 2
c 4
b 0
f 0
dl 0
loc 7
rs 9.4285
1
#!/usr/bin/python
2
# -*- coding: utf-8 -*-
3
u"""
4
:author: Joseph Martinot-Lagarde
5
6
Created on Sat Jan 19 14:57:57 2013
7
"""
8
9
from __future__ import (
10
    print_function, division, unicode_literals, absolute_import)
11
12
13
import subdir.profiling_test_script2 as script2
14
15
16
@profile
17
def fact(n):
18
    result = 1
19
    for i in xrange(2, n // 4):
20
        result *= i
21
    result = 1
22
    # This is a comment
23
    for i in xrange(2, n // 16):
24
        result *= i
25
    result = 1
26
27
    if False:
28
        # This won't be run
29
        raise RuntimeError("What are you doing here ???")
30
31
    for i in xrange(2, n + 1):
32
        result *= i
33
    return result
34
    # This is after the end of the function.
35
36
    if False:
37
        # This won't be run
38
        raise RuntimeError("It's getting bad.")
39
40
41
@profile
42
def sum_(n):
43
    result = 0
44
45
    for i in xrange(1, n + 1):
46
        result += i
47
    return result
48
49
if __name__ == "__main__":
50
    print(fact(120))
51
    print(sum_(120))
52
    print(script2.fact2(120))
53
    print(script2.sum2(120))
54