using System;
using System.Threading;

class X {
	static int nreq;
	static void Main ()
	{
		Console.WriteLine ("Warming the server up");
		TestService ts = new TestService ();
		ts.Add (1, 100);
		DateTime start = DateTime.UtcNow;
		Console.WriteLine ("Press ENTER to finish.");
		for (int i = 0; i < 8; i ++) {
			Thread th = new Thread (new ThreadStart (W));
			th.IsBackground = true;
			th.Start ();
		}
		Console.ReadLine ();
		DateTime stop = DateTime.UtcNow;
		TimeSpan diff = stop - start;
		double seconds = diff.TotalSeconds;
		int n = Interlocked.CompareExchange (ref nreq, 0, 0);
		Console.WriteLine ("Requests: {0}\nTotal time: {1}\nR/S: {2}", n, seconds, n / seconds);
	}

	static void W ()
	{
		TestService ts = new TestService ();
		while (true) {
			if (ts.Add (1, 100) != 101)
				Console.WriteLine ("ERROR!!!");

			int i = Interlocked.Increment (ref nreq);
			if ((i % 100) == 0)
				Console.WriteLine (i);
		}
	}
}



/// <remarks/>
[System.Web.Services.WebServiceBinding(Name="TestServiceSoap",Namespace="http://tempuri.org/"),
System.Diagnostics.DebuggerStepThroughAttribute(),
System.ComponentModel.DesignerCategoryAttribute("code")]
public class TestService: System.Web.Services.Protocols.SoapHttpClientProtocol {

    public TestService () {
        this.Url = "http://127.0.0.1:8080/TestService.asmx";
    }

    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/Echo",
         RequestNamespace="http://tempuri.org/",ResponseNamespace="http://tempuri.org/",
         ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped,
         Use=System.Web.Services.Description.SoapBindingUse.Literal)]
    public string Echo(string a) {
        object[] results = this.Invoke("Echo", new object[] {
            a});
        return ((string)(results[0]));
    }

    public System.IAsyncResult BeginEcho(string a, System.AsyncCallback callback, object
          asyncState) {
        return this.BeginInvoke("Echo", new object[] {
            a}, callback, asyncState);
    }

    public string EndEcho(System.IAsyncResult asyncResult) {
        object[] results = this.EndInvoke(asyncResult);
        return ((string)(results[0]));
    }

    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/Add",
         RequestNamespace="http://tempuri.org/",ResponseNamespace="http://tempuri.org/",
         ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped,
         Use=System.Web.Services.Description.SoapBindingUse.Literal)]
    public int Add(int a, int b) {
        object[] results = this.Invoke("Add", new object[] {
            a,
            b});
        return ((int)(results[0]));
    }

    public System.IAsyncResult BeginAdd(int a, int b, System.AsyncCallback callback, object
          asyncState) {
        return this.BeginInvoke("Add", new object[] {
            a,
            b}, callback, asyncState);
    }

    public int EndAdd(System.IAsyncResult asyncResult) {
        object[] results = this.EndInvoke(asyncResult);
        return ((int)(results[0]));
    }
}

