Bug 607719: revamp the testconfig setup (r=brbaker)
[tamarin-stm.git] / vprof / testVprofMT.c
blob85f02095c18c3d970b7923f2ab3011d0337c71fa
1 /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is Value-Profiling Utility.
17 * The Initial Developer of the Original Code is
18 * Intel Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 2008
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Mohammad R. Haghighat [mohammad.r.haghighat@intel.com]
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #include <windows.h>
40 #include <stdio.h>
41 #include <time.h>
43 #include "vprof.h"
45 static void cProbe (void* vprofID)
47 if (_VAL == _IVAR1) _I64VAR1 ++;
48 _IVAR1 = _IVAR0;
50 if (_VAL == _IVAR0) _I64VAR0 ++;
51 _IVAR0 = (int) _VAL;
53 _DVAR0 = ((double)_I64VAR0) / _COUNT;
54 _DVAR1 = ((double)_I64VAR1) / _COUNT;
57 //__declspec (thread) boolean cv;
58 //#define if(c) cv = (c); _vprof (cv); if (cv)
59 //#define if(c) cv = (c); _vprof (cv, cProbe); if (cv)
61 #define THREADS 1
62 #define COUNT 100000
63 #define SLEEPTIME 0
65 static int64_t evens = 0;
66 static int64_t odds = 0;
68 void sub(int val)
70 int i;
71 //_vprof (1);
72 for (i = 0; i < COUNT; i++) {
73 //_nvprof ("Iteration", 1);
74 //_nvprof ("Iteration", 1);
75 _vprof (i);
76 //_vprof (i);
77 //_hprof(i, 3, (int64_t) 1000, (int64_t)2000, (int64_t)3000);
78 //_hprof(i, 3, 10000, 10001, 3000000);
79 //_nhprof("Event", i, 3, 10000, 10001, 3000000);
80 //_nhprof("Event", i, 3, 10000, 10001, 3000000);
81 //Sleep(SLEEPTIME);
82 if (i % 2 == 0) {
83 //_vprof (i);
84 ////_hprof(i, 3, 10000, 10001, 3000000);
85 //_nvprof ("Iteration", i);
86 evens ++;
87 } else {
88 //_vprof (1);
89 _vprof (i, cProbe);
90 odds ++;
92 //_nvprof ("Iterate", 1);
94 //printf("sub %d done.\n", val);
97 HANDLE array[THREADS];
99 static int run (void)
101 int i;
103 time_t start_time = time(0);
105 for (i = 0; i < THREADS; i++) {
106 array[i] = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)sub, (LPVOID)i, 0, 0);
109 for (i = 0; i < THREADS; i++) {
110 WaitForSingleObject(array[i], INFINITE);
113 return 0;
116 int main ()
118 DWORD start, end;
120 start = GetTickCount ();
121 run ();
122 end = GetTickCount ();
124 printf ("\nRun took %d msecs\n\n", end-start);