File: csperftest.cs

package info (click to toggle)
clearsilver 0.10.5-1.4
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,272 kB
  • ctags: 3,138
  • sloc: ansic: 24,586; python: 4,233; sh: 2,502; cs: 1,429; ruby: 819; java: 735; makefile: 603; perl: 120; lisp: 34; sql: 21
file content (49 lines) | stat: -rw-r--r-- 1,200 bytes parent folder | download | duplicates (8)
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
using System;
using System.Runtime.InteropServices;

using Clearsilver;


public class CSPerfTest {
   public delegate void test_function(int INDEX);

    public static void timefunk(String label, test_function f, int count) {
      int start, end, elapsed;
      start = Environment.TickCount;
      f(count);
      end = Environment.TickCount;

      elapsed = end-start;

      Console.WriteLine(label + "   " + count + " elapsed: " + (elapsed / 1000.0));
    }

   public static unsafe int Main(string[] argv) {
      Console.WriteLine("C# Clearsilver wrapper performance test");
      Hdf h = new Hdf();

      h.setValue("foo.1","1");
      h.setValue("foo.2","2");

      int call_count = 100000;
      int start = Environment.TickCount;
      for (int i=0;i<call_count;i++) {
         h.setValue(String.Format("foo.{0}",i),"5");
      }
      int end = Environment.TickCount;

      Console.WriteLine("call count = {0}, time = {1} ms - time per call {2} ns", 
           call_count, end-start, (((float)end-start)/call_count) * 1000);
      

      CSTContext cs = new CSTContext(h);
//      cs.parseFile("test.cst");
      Console.WriteLine(cs.render());
      
      return 0;
   }
  


}