Click here to Skip to main content
15,892,517 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionDouble Datatype and .NET Pin
Ray Kinsella15-May-07 6:40
Ray Kinsella15-May-07 6:40 
AnswerRe: Double Datatype and .NET Pin
Dave Kreskowiak15-May-07 7:25
mveDave Kreskowiak15-May-07 7:25 
GeneralRe: Double Datatype and .NET Pin
Ray Kinsella15-May-07 11:21
Ray Kinsella15-May-07 11:21 
AnswerRe: Double Datatype and .NET [modified] Pin
Not Active15-May-07 8:19
mentorNot Active15-May-07 8:19 
GeneralRe: Double Datatype and .NET Pin
Dave Kreskowiak15-May-07 9:24
mveDave Kreskowiak15-May-07 9:24 
GeneralRe: Double Datatype and .NET Pin
Not Active15-May-07 9:34
mentorNot Active15-May-07 9:34 
GeneralRe: Double Datatype and .NET Pin
Dave Kreskowiak15-May-07 10:19
mveDave Kreskowiak15-May-07 10:19 
GeneralRe: Double Datatype and .NET [modified] Pin
Dave Kreskowiak15-May-07 10:43
mveDave Kreskowiak15-May-07 10:43 
Well, not so fast. Rewriting the test in both languages, I got the same results as you. The Debug version is now SLOWER
The VB.NET version I used:
Public Class Form1
    Inherits System.Windows.Forms.Form
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Button1.Enable = False
        Application.DoEvents()
 
        Dim i, j, t As Double
        Dim StartTime As DateTime = DateTime.Now
 
        For i = 0 to 10000
            For j = 0 to 10000
                t += i + j
            Next
        Next
 
        Dim EndTime As DateTime = DateTime.Now
        Dim TotalTime As TimeSpan = EndTime - StartTime
        Console.WriteLine("TotalTime: " & TotalTime.TotalMilliseconds)
 
        Button1.Enabled = True
End Sub

The C# version is, line-for-line, identical to this, even the IL is the same.
using System;
using System.Collections.Generic;
using System.Windows.Forms;
blah, blah, blah
 
namespace Double_Performance_Test
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitalizeComponent();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            button1.Enabled = false;
            Application.DoEvents();
 
            double i, j, t = 0.0;
 
            DateTime StartTime = DateTime.Now;
 
            for (i=0; i < 10000; i++)
                for (j=0; j < 10000; j++)
                    t += i + j;
 
            DateTime EndTime = DateTime.Now;
            TimeSpan TotalTime = EndTime - StartTime;
            Console.WriteLine("Total Time: " + TotalTime.TotalMilliseconds);
 
            button1.Enabled = true;
        }
    }
}

Both get the same results:
  Debug: avg of 3460 ms
Release: avg of 820 ms






-- modified at 16:48 Tuesday 15th May, 2007

A guide to posting questions on CodeProject[^]

Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007


GeneralRe: Double Datatype and .NET Pin
Ray Kinsella15-May-07 11:19
Ray Kinsella15-May-07 11:19 
GeneralRe: Double Datatype and .NET Pin
Dave Kreskowiak15-May-07 12:58
mveDave Kreskowiak15-May-07 12:58 
GeneralRe: Double Datatype and .NET Pin
Not Active15-May-07 15:04
mentorNot Active15-May-07 15:04 
GeneralRe: Double Datatype and .NET Pin
Ray Kinsella15-May-07 11:18
Ray Kinsella15-May-07 11:18 
QuestionSerialPort.Open() question... Pin
SirTreveyan15-May-07 3:13
SirTreveyan15-May-07 3:13 
AnswerRe: SerialPort.Open() question... Pin
pbraun18-May-07 16:47
pbraun18-May-07 16:47 
QuestionImageDirectoryEntryToDataEx() not working Pin
priyank_ldce15-May-07 0:22
priyank_ldce15-May-07 0:22 
Questionurgent help Pin
shruthis914-May-07 21:19
shruthis914-May-07 21:19 
AnswerRe: urgent help Pin
Colin Angus Mackay15-May-07 2:00
Colin Angus Mackay15-May-07 2:00 
AnswerRe: urgent help Pin
Dave Kreskowiak15-May-07 4:39
mveDave Kreskowiak15-May-07 4:39 
AnswerRe: urgent help Pin
Pete O'Hanlon15-May-07 9:13
mvePete O'Hanlon15-May-07 9:13 
AnswerRe: urgent help Pin
Navneet Hegde15-May-07 18:49
Navneet Hegde15-May-07 18:49 
QuestionOOPS Pin
Navneet Hegde14-May-07 18:47
Navneet Hegde14-May-07 18:47 
AnswerRe: OOPS Pin
Giorgi Dalakishvili14-May-07 23:06
mentorGiorgi Dalakishvili14-May-07 23:06 
JokeRe: OOPS Pin
Pete O'Hanlon15-May-07 0:32
mvePete O'Hanlon15-May-07 0:32 
AnswerRe: OOPS [modified] Pin
Jaiprakash M Bankolli15-May-07 2:39
Jaiprakash M Bankolli15-May-07 2:39 
GeneralRe: OOPS Pin
Giorgi Dalakishvili15-May-07 8:20
mentorGiorgi Dalakishvili15-May-07 8:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.