-
Notifications
You must be signed in to change notification settings - Fork 0
/
RemotingExperiment.cs
61 lines (54 loc) · 1.47 KB
/
RemotingExperiment.cs
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
/* RemotingExperiment
*
* Experiment with Remoting in Mono
*
* (c) 2008 Emanuele Aina <em@nerd.ocracy.org>
* http://nerd.ocracy.org/em
*
* Do whatever you want with it.
*/
using System;
using System.Threading;
public class RemotingExperiment
{
public static int Main(string[] args)
{
if(args.Length == 0)
return Run();
else
return Help();
}
public static int Run()
{
DoSomething doSomething;
TimeSpan time;
Console.WriteLine("Measuring remote");
using(Remoting helper = new Remoting()) {
helper.Start("RemotingHelper.exe", helper.SocketPath);
doSomething = helper.Get<DoSomething>();
time = Do(doSomething);
}
Console.WriteLine("Elapsed (remote): {0}", time);
Console.WriteLine("Measuring local");
doSomething = new DoSomething();
time = Do(doSomething);
Console.WriteLine("Elapsed (local): {0}", time);
return 0;
}
public static TimeSpan Do(DoSomething doSomething)
{
DateTime start = DateTime.Now;
while(!doSomething.HaveYouFinished()) {
object[] results = doSomething.WhatsUp();
// just to say that whe use the results
results.ToString();
}
DateTime end = DateTime.Now;
return end - start;
}
public static int Help()
{
Console.WriteLine("Usage: RemotingExperiment.exe");
return 1;
}
}