1 using System;
2 using System.Runtime.InteropServices;
3 
4 using Clearsilver;
5 
6 
7 public class CSPerfTest {
test_function(int INDEX)8    public delegate void test_function(int INDEX);
9 
timefunk(String label, test_function f, int count)10     public static void timefunk(String label, test_function f, int count) {
11       int start, end, elapsed;
12       start = Environment.TickCount;
13       f(count);
14       end = Environment.TickCount;
15 
16       elapsed = end-start;
17 
18       Console.WriteLine(label + "   " + count + " elapsed: " + (elapsed / 1000.0));
19     }
20 
Main(string[] argv)21    public static unsafe int Main(string[] argv) {
22       Console.WriteLine("C# Clearsilver wrapper performance test");
23       Hdf h = new Hdf();
24 
25       h.setValue("foo.1","1");
26       h.setValue("foo.2","2");
27 
28       int call_count = 100000;
29       int start = Environment.TickCount;
30       for (int i=0;i<call_count;i++) {
31          h.setValue(String.Format("foo.{0}",i),"5");
32       }
33       int end = Environment.TickCount;
34 
35       Console.WriteLine("call count = {0}, time = {1} ms - time per call {2} ns",
36            call_count, end-start, (((float)end-start)/call_count) * 1000);
37 
38 
39       CSTContext cs = new CSTContext(h);
40 //      cs.parseFile("test.cst");
41       Console.WriteLine(cs.render());
42 
43       return 0;
44    }
45 
46 
47 
48 }
49 
50