aboutsummaryrefslogtreecommitdiffstats
path: root/src/VMTestsFiller/loop-mul.sol
blob: 116970d48536a9dd546aaad7cdeab2ca3ca3c0d4 (plain) (blame)
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
pragma solidity ^0.4.0;

contract MulPerformanceTester {

    function testMulMod(uint x, uint y, uint k, uint n) external returns (uint) {
        var r = x;
        for (uint i = 0; i < n; i += 1) {
            r = mulmod(r, y, k);
        }
        return r;
    }

    function testDivAdd(uint x, uint y, uint k, uint n) external returns (uint) {
        var r = x;
        for (uint i = 0; i < n; i += 1) {
            r /= y;
            r += k;
        }
        return r;
    }

    function testMul(uint x, uint y, uint n) external returns (uint) {
        var r = x;
        for (uint i = 0; i < n; i += 1) {
            r *= y;
        }
        return r;
    }

    function testAdd(uint x, uint y, uint n) external returns (uint) {
        var r = x;
        for (uint i = 0; i < n; i += 1) {
            r += y;
        }
        return r;
    }
}