Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using System;
using System.Runtime.CompilerServices;
namespace LeckerBrot
{
public class RowCalulator
{
public void Calc() {
for (int i = 0; i < 100000000; i++) {
double zr = 0, zi = 0;
for (int j = 0; j < 10; j++) {
CalculatePoint (12, 12, ref zr, ref zi);
}
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void CalculatePoint(double cr, double ci, ref double zr, ref double zi) {
var zr_old = zr;
zr = (zr * zr - zi * zi) + cr;
zi = 2 * (zi * zr_old) + ci;
}
}
}
using System;
using System.Runtime.CompilerServices;
namespace LeckerBrot
{
public class RowCalulator
{
public void Calc() {
for (int i = 0; i < 100000000; i++) {
double zr = 0, zi = 0;
for (int j = 0; j < 10; j++) {
double cr = 12, ci = 12;
var zr_old = zr;
zr = (zr * zr - zi * zi) + cr;
zi = 2 * (zi * zr_old) + ci;
}
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
public void CalculatePoint(double cr, double ci, ref double zr, ref double zi) {
}
}
}
using System;
using System.Runtime.CompilerServices;
namespace LeckerBrot
{
public class RowCalulator
{
public void Calc() {
for (int i = 0; i < 100000000; i++) {
double zr = 0, zi = 0;
for (int j = 0; j < 10; j++) {
CalculatePoint (12, 12, ref zr, ref zi);
}
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
public void CalculatePoint(double cr, double ci, ref double zr, ref double zi) {
var zr_old = zr;
zr = (zr * zr - zi * zi) + cr;
zi = 2 * (zi * zr_old) + ci;
}
}
}
using System;
using System.Diagnostics;
namespace LeckerBrot
{
class MainClass
{
public static void Main (string[] args)
{
Stopwatch watch = new Stopwatch ();
RowCalulator calc = new RowCalulator ();
watch.Start ();
calc.Calc ();
watch.Stop ();
Console.WriteLine (watch.ElapsedTicks);
}
}
}
@moritzuehling

This comment has been minimized.

Copy link
Owner Author

moritzuehling commented Aug 11, 2015

Mono Version

$ mono --version
Mono JIT compiler version 4.0.3 (Stable 4.0.3.20/d6946b4 Tue Aug  4 09:43:57 UTC 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com

Results

Profile is always release

Arch Inlining Time taken Relative Time
x86 Aggressive (Attribute) 147687387 100%
x86 No Inlining (Attribute) 146419297 99.14%
x86 Manually Inlined 97312791 65.89%

Configuration

Compiling

Other System Information

Processor: Intel(R) Core(TM) i7-4700MQ CPU @ 2.40GHz

$ uname -a
Linux moritz-P15SM 3.19.0-15-generic #15-Ubuntu SMP Thu Apr 16 23:32:37 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.