473,836 Members | 1,521 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C++/CLI the fastest compiler? Yes, at least for me. :-)

Ok, so I posted a rant earlier about the lack of marketing for C++/CLI,
and it forked over into another rant about which was the faster
compiler. Some said C# was just as fast as C++/CLI, whereas others said
C++/CLI was more optimized.

Anyway, I wrote up some very simple test code, and at least on my
computer C++/CLI came out the fastest. Here's the sample code, and just
for good measure I wrote one in java, and it was the slowest! ;-) Also,
I did no optimizing compiler switches and compiled the C++/CLI with
/clr:safe only to compile to pure verifiable .net.

//C++/CLI code
using namespace System;

int main()
long start = Environment::Ti ckCount;
for (int i = 0; i < 10000000; ++i) {}
long end = Environment::Ti ckCount;
Console::WriteL ine(end - start);
//C# code
using System;

public class ForLoopTest
public static void Main(string[] args)
long start = Environment.Tic kCount;
for (int i =0;i < 10000000; ++i) {}
long end = Environment.Tic kCount;
Console.WriteLi ne((end-start));

//Java code
public class Performance
public static void main(String args[])
long start = System.currentT imeMillis();
for (int i=0; i < 10000000; ++i) {}
long end = System.currentT imeMillis();
System.out.prin tln(end-start);


C++/CLI -> 15-18 secs
C# -> 31-48 secs
Java -> 65-72 secs

I know, I know, these kind of test are not always foolproof, and results
can vary by computer to computer, but at least on my system, C++/CLI had
the fastest results.

Maybe C++/CLI is the most optimized compiler?

-Don Kim
Mar 12 '06
44 3238
This is very useful info. It was causing confusion given mixed
information coming from MSFT itself.

Ajay Kalra
aj*******@yahoo .com

Mar 13 '06 #41

"Carl Daniel [VC++ MVP]" <cp************ *************** **@mvps.org.nos pam>
wrote in message news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
| "Willy Denoyette [MVP]" <wi************ *@telenet.be> wrote in message
| news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
| > Followup.
| > !!! Stopwatch.Elaps ed.Ticks != Stopwatch.Elaps edTicks !!!
| A ha! I obviously hadn't looked at the code closely enough to realize
| it was using Elapsed.Ticks and not ElapsedTicks.
| > One should not use Elapsed.Ticks to calculate the elapsed time in
| > nanoseconds.
| True - one should use it to calculate the elapsed time in 0.1us units,
| that's what TimeSpan.Ticks is expressed as.
| > The only correct way to get this high precision count is by using
| > Stopwatch.Elaps edTicks like this:
| >
| > long nanosecPerTick = (1000L*1000L*10 00L) / Stopwatch.Frequ ency;
| but make this a double. Stopwatch.Frequ ency is more than 1E9 on modern
| machines using the MP HAL.
| double nanosecPerTick = 1000.0 * 1000L * 1000L / Stopwatch.Frequ ency;
Sure, or use picoseconds :-)

long picosecPerTick = 1000L * 1000L * 1000L * 1000L / Stopwatch.Frequ ency;

90614831400 picoseconds
Looks real crazy isn't it?

Mar 13 '06 #42

"Ajay Kalra" <aj*******@yaho o.com> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.com.. .
| This is very useful info. It was causing confusion given mixed
| information coming from MSFT itself.
| --------
| Ajay Kalra
| aj*******@yahoo .com

Well, the C++/CLI team did not want to generate explicit sequence points in
the IL, so the JIT compiler can only rely on the implicit sequence points
(that is when the evaluation stack is empty). That means also that it's not
possible to synchronise the IL with the actual code while debugging C++/CLI
in managed mode and you need the PDB to set breakpoint in your code, not a
big deal IMO.
Mar 13 '06 #43
"Willy Denoyette [MVP]" <wi************ *@telenet.be> wrote in message
news:Om******** ******@TK2MSFTN GP09.phx.gbl...
Sure, or use picoseconds :-)

Nah - that's short sighted. Let's standardize on Attoseconds :)

long attosecPerTick = 1000L * 1000L * 1000L * 1000L * 1000L * 1000L
/Stopwatch.Frequ ency;

now that's just getting silly... for the next few decades at least.

Mar 14 '06 #44

"Carl Daniel [VC++ MVP]" <cp************ *************** **@mvps.org.nos pam>
wrote in message news:OJ******** ******@tk2msftn gp13.phx.gbl...
| "Willy Denoyette [MVP]" <wi************ *@telenet.be> wrote in message
| news:Om******** ******@TK2MSFTN GP09.phx.gbl...
| > Sure, or use picoseconds :-)
| Nah - that's short sighted. Let's standardize on Attoseconds :)
| long attosecPerTick = 1000L * 1000L * 1000L * 1000L * 1000L * 1000L
| /Stopwatch.Frequ ency;
| now that's just getting silly... for the next few decades at least.
| -cd

LOL, I'll keep it in mind for a next life maybe :-)

Mar 15 '06 #45

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Rune Strand | last post by:
Hi, If I have a lot of integers and want do something with each digit as integer, what is the fastest way to get there? Eg. Make 12345 into an iterable object, like or "12345" (Btw: What is the English term for this process; itemize? tokenize? digitize? sequence?) Some examples:
by: Montrose... | last post by:
After working in c# for a year, the only conclusion I can come to is that I wish I knew c. All I need is Linux, the gnu c compiler and I can do anything. Web services are just open sockets hooked up to interfaces. The Gtk is more than enough gui.
by: Klaas Vantournhout | last post by:
Hi, I have a question, which is just out of interest. What is the fastest way to do an odd/even check with c++ and if needed assembler. Assume n is an unsigned integer like type (unsigned int, unsigned long int), what is the fastest? using the modulo operator
by: ThunderMusic | last post by:
Hi, The subject says it all... I want to use a byte and use it as byte* so I can increment the pointer to iterate through it. What is the fastest way of doing so in C#? Thanks ThunderMusic
by: SETT Programming Contest | last post by:
The SETT Programming Contest: The fastest set<Timplementation Write the fastest set<Timplementation using only standard C++/C. Ideally it should have the same interface like std::set. At least the following methods must be implemented: insert(), find(), begin(), end(), erase(), size(), operator<(), and at least the forward iterator. Here, speed and correctness are the 2 most important factors. Functionally it should behave similar to...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.