Click here to Skip to main content
15,888,351 members
Home / Discussions / C#
   

C#

 
AnswerRe: Speed of execution Pin
AspDotNetDev16-Sep-11 7:02
protectorAspDotNetDev16-Sep-11 7:02 
AnswerRe: Speed of execution Pin
Luc Pattyn16-Sep-11 7:18
sitebuilderLuc Pattyn16-Sep-11 7:18 
AnswerRe: Speed of execution Pin
Eddy Vluggen16-Sep-11 9:51
professionalEddy Vluggen16-Sep-11 9:51 
GeneralRe: Speed of execution Pin
AspDotNetDev16-Sep-11 10:38
protectorAspDotNetDev16-Sep-11 10:38 
AnswerRe: Speed of execution Pin
Eddy Vluggen16-Sep-11 11:03
professionalEddy Vluggen16-Sep-11 11:03 
GeneralRe: Speed of execution Pin
AspDotNetDev16-Sep-11 11:20
protectorAspDotNetDev16-Sep-11 11:20 
AnswerRe: Speed of execution Pin
Eddy Vluggen16-Sep-11 11:33
professionalEddy Vluggen16-Sep-11 11:33 
NewsRe: Speed of execution Pin
Eddy Vluggen16-Sep-11 13:44
professionalEddy Vluggen16-Sep-11 13:44 
Two comparable snippets;
C#
class Program
{
    static List<String> numbersList = new List<string>();
    static void Main(string[] args)
    {
        int start = Environment.TickCount;
        while (Environment.TickCount - start < 5000)
        {
            numbersList.Add("Tick " + Environment.TickCount);
        }
        Console.WriteLine(numbersList.Count);
        Console.ReadKey();
    }
}

Delphi
procedure Test1();
var start: dword;
    numbersList: TStringList;
begin
  numbersList := TStringList.Create();
  start := GetTickCount();
  while GetTickCount() - start < 5000 do
  begin
    numbersList.Add('Tick ' + IntToStr(GetTickCount()));
  end;
  WriteLn(numbersList.Count);
  numbersList.Clear;
  numbersList.Free;
end;

begin
  Test1();
  ReadLn();
end.  

C# managed to create 3.413.266 objects (in release mode, set to x86). Lazarus TCreated a 5.295.911 items without knowing about my cpu.

FWIW, if I convert the example that the TS provided to Delphi, I come out at 43 ms (included for those that want to run their own tests);
Delphi
procedure Test2();
const testSize = 10000000;
var start: dword;
    data : array[0..testSize] of byte;
    i    : integer;
begin
  start := GetTickCount();
  for i := 0 to testSize do
  begin
     data[i] := 128;
  end;
  WriteLn('Safe time ' +  IntToStr(GetTickCount() - start) + ' ms');
end;

..and I might want to add that you should measure using timeGetTime(), not using GetTickCount. Wish I had VB6 here to give it a try, in both native and P-code versions. My first boss would disagree with the provided testcode, as there's a more efficient version;
Delphi
procedure Test2();
const testSize = 10000000;
var start: dword;
    data : array[0..testSize] of byte;
begin
  start := GetTickCount();
  FillChar(data, SizeOf(data), 128);
  WriteLn('Safe time ' +  IntToStr(GetTickCount() - start) + ' ms');
end;

This does it in 15 ms. That doesn't mean I'm switching back! .NET does the most things in an effective way, despite all the metadata and the wrappers. Plus, it provides a lot of convenience.

We've got profilers that work a lot better than the old timeGetTime API, and we got a lot of goodies that support building an application quickly, with a damn good performance.
Bastard Programmer from Hell Suspicious | :suss:

QuestionUndo functionality for Node rename in TreeView Pin
Nyanoba16-Sep-11 1:28
Nyanoba16-Sep-11 1:28 
AnswerRe: Undo functionality for Node rename in TreeView Pin
BillWoodruff16-Sep-11 2:26
professionalBillWoodruff16-Sep-11 2:26 
AnswerRe: Undo functionality for Node rename in TreeView Pin
BobJanova16-Sep-11 3:51
BobJanova16-Sep-11 3:51 
GeneralRe: Undo functionality for Node rename in TreeView Pin
BillWoodruff16-Sep-11 17:01
professionalBillWoodruff16-Sep-11 17:01 
GeneralRe: Undo functionality for Node rename in TreeView Pin
Nyanoba19-Sep-11 19:22
Nyanoba19-Sep-11 19:22 
QuestionShow a hidden console again? Pin
Don Rolando15-Sep-11 22:49
Don Rolando15-Sep-11 22:49 
AnswerRe: Show a hidden console again? Pin
V.15-Sep-11 23:16
professionalV.15-Sep-11 23:16 
GeneralRe: Show a hidden console again? Pin
Don Rolando15-Sep-11 23:18
Don Rolando15-Sep-11 23:18 
GeneralRe: Show a hidden console again? Pin
V.15-Sep-11 23:37
professionalV.15-Sep-11 23:37 
GeneralRe: Show a hidden console again? Pin
Don Rolando16-Sep-11 0:23
Don Rolando16-Sep-11 0:23 
GeneralRe: Show a hidden console again? Pin
V.16-Sep-11 0:36
professionalV.16-Sep-11 0:36 
GeneralRe: Show a hidden console again? Pin
Don Rolando16-Sep-11 0:47
Don Rolando16-Sep-11 0:47 
AnswerRe: Show a hidden console again? Pin
Alan N16-Sep-11 3:04
Alan N16-Sep-11 3:04 
GeneralRe: Show a hidden console again? Pin
Don Rolando16-Sep-11 3:19
Don Rolando16-Sep-11 3:19 
AnswerRe: Show a hidden console again? Pin
PIEBALDconsult16-Sep-11 3:19
mvePIEBALDconsult16-Sep-11 3:19 
GeneralRe: Show a hidden console again? Pin
Don Rolando16-Sep-11 3:22
Don Rolando16-Sep-11 3:22 
QuestionDataGridView throws Data Pin
beauroak15-Sep-11 15:15
beauroak15-Sep-11 15:15 

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.