Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. PERFORMANCE PROBLEM C# vs C++

PERFORMANCE PROBLEM C# vs C++

Scheduled Pinned Locked Moved C / C++ / MFC
csharpvisual-studioquestionc++css
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kobi10i10
    wrote on last edited by
    #1

    i wrote the same code both in VISUALL C++ AND C#. in both cases, the OPTIMIZED SWITCH is turned on. the results: in C#, around 300 msec, in c++ less then 1 msec. what is happening here??? in general i need to process 4 megabyte each 250 msec, and it looks likt c# is not the answer... or maybe there is another optimize switch in c# i am not aware of (beside the one in the BUILD TAB). can someone please advice? is it true c# is not good for real time? THE CODE in visual studio 2005 c#: =================================================================================== using System; using System.Collections.Generic; using System.Text; using System.Diagnostics ; namespace ConsoleApplication10 { class Program { static void Main(string[] args) { byte []byte1=new byte[2097152*2]; byte[] byte2=new byte[2097152*2]; Stopwatch sw=new Stopwatch (); sw.Start (); for(int i=0;i<2097152*2;i++) { for(int y=0;y<64;y++) { if(byte1[y]==byte2[y]) //if (*(bytes1+i)==*(bytes2+i)) { } } } sw.Stop (); Console.Write ("{0}",sw.ElapsedMilliseconds ) ; Console.ReadKey (); } } } THE CODE IN VISUALL C++ 2005: =============================== #include "stdafx.h" #using #using #using using namespace System; using namespace System::Diagnostics; using namespace System::Windows::Forms; using namespace System::Drawing; using namespace System::Drawing::Drawing2D; int _tmain(int argc, _TCHAR* argv[]) { char *bytes1=new char[2097152*2]; char *bytes2=new char[2097152*2]; Stopwatch^ stopWatch; stopWatch = gcnew Stopwatch; stopWatch->Start (); //for (int u=0;u<10000;u++) for (int i=0;i<2097152*2;i++) { for (int y=0;y<64;y++) { if (bytes1[y]==bytes2[y]) //if (*(bytes1+i)==*(bytes2+i)) { } } } long ii; ii =(long)stopWatch->ElapsedMilliseconds; stopWatch->Stop (); printf("%d",ii); //ElapsedMilliseconds Ticks return 0; }

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups