Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Benchmark {
- Random rnd = new Random();
- [Benchmark]
- public int CustomFunction1() {
- int sum = 0;
- for (int i = 0; i < GetCustomValue(); i++) {
- sum += i;
- }
- return sum;
- }
- [Benchmark]
- public int CustomFunction2() {
- int sum = 0;
- for (int i = 0; i < GetCustomValue(i); i++) {
- sum += i;
- }
- return sum;
- }
- [MethodImpl(MethodImplOptions.NoInlining)]
- int GetCustomValue(int i) {
- int a = rnd.Next(i);
- return a > 1000 ? 100 : 10;
- }
- int GetCustomValue() {
- int a = rnd.Next(100);
- return a > 1000 ? 100 : 10;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement