[System] Tweak socket test
[mono-project.git] / mono / profiler / test-busy.cs
blob275f417a2dcde2cfc5717b844e1e3ae6aa64c614
1 using System;
2 using System.Threading;
4 class T {
6 static int count = 10;
7 static void test2 () {
8 //Thread.Sleep (500);
9 //return;
10 int v = 0;
11 for (int i = 0; i < count; ++i) {
12 v += test3 ();
16 static int test3 () {
17 int v = 33;
18 for (int i = 0; i < 10000000; ++i) {
19 v += i * 1000;
20 v /= (1 + i) * 2;
22 return v > 0? 0: 1;
24 static int test () {
25 int v = 33;
26 for (int i = 0; i < 10000000; ++i) {
27 v += i * 1000;
28 v /= (1 + i) * 2;
30 return v > 0? 0: 1;
32 static int Main (string[] args) {
33 if (args.Length > 0)
34 count = int.Parse (args [0]);
35 Thread t = new Thread (test2);
36 t.Name = "BusyHelper";
37 t.Start ();
38 int v = 0;
39 for (int i = 0; i < count; ++i) {
40 v += test ();
42 t.Join ();
43 return v > 0? 0: 1;