Esempio n. 1
0
    /**
     * testInvokeOfAnInstanceMethodWithoutInterface.
     *
     * @return
     */
    public static long testInvokeOfAnInstanceMethodWithSetInstanceVariable()
    {
        int            count  = 0;
        InvokeInstance invoke = new InvokeInstance();
        DateTime       start  = DateTime.Now;

        for (int i = NB_INVOKE_SETTER_TESTS; i != 0; i--)
        {
            // Write to force jre not to optimize the code
            if (i % 2 == 0)
            {
                count = count + invoke.echoWithSetVariable("0").Length;
            }
            else
            {
                count = count + invoke.echoWithSetVariable("1").Length;
            }
        }
        DateTime end           = DateTime.Now;
        TimeSpan executionTime = end - start;

        Console.WriteLine("[InvokeTest], Invoke Of An Instance Method With Set Instance Variable " + NB_INVOKE_TESTS + " invoke.echoWithSetVariable(\"1\").Length, count=" + count + ", snapshot time,"
                          + executionTime.TotalMilliseconds);
        return((long)executionTime.TotalMilliseconds);
    }
 /**
  * testInvokeOfAnInstanceMethodWithoutInterface.
  *
  * @return
  */
 public static long testInvokeOfAnInstanceMethodWithSetInstanceVariable()
 {
     int count = 0;
     InvokeInstance invoke = new InvokeInstance();
     DateTime start = DateTime.Now;
     for (int i = NB_INVOKE_SETTER_TESTS; i != 0; i--)
     {
         // Write to force jre not to optimize the code
         if (i % 2 == 0)
         {
             count = count + invoke.echoWithSetVariable("0").Length;
         }
         else
         {
             count = count + invoke.echoWithSetVariable("1").Length;
         }
     }
     DateTime end = DateTime.Now;
     TimeSpan executionTime = end - start;
     Console.WriteLine("[InvokeTest], Invoke Of An Instance Method With Set Instance Variable " + NB_INVOKE_TESTS + " invoke.echoWithSetVariable(\"1\").Length, count=" + count + ", snapshot time,"
         + executionTime.TotalMilliseconds);
     return (long)executionTime.TotalMilliseconds;
 }