Performance: CLI vs Win32 API

In my little free time I develop some open source projects, for example my last creature is “Minimalistic Explorer“. This project is made in C# WPF for the UI and actually core is written in C#, but I hope to port the existing core in C++/CLI.

hd_me_735243

The main task of this program is list files and a common question is what is the better way to list all files/directories?

I have written a simple C++/CLI program that call DirectoryInfo::GetDirectories and FindFirstFile Win32 API method. At this point, I request to list all entry of “C:\Windows\winsxs” folder. This folder contains a lot of elements.

This is the results:


Performance test
.NET 00:00:00.1400080
Count 6459
Win32 00:00:00.0260015
Count 6462

The first results is for .NET and the second is for Win32 API. This is an empirical test but the result can be a reflection point about performance consideration from C++ and .NET code.

Source code and executable can be download here. Note:  The downloaded source/executable have a different output order, I have re-ordered the output to clarify the output.

2 Responses to “Performance: CLI vs Win32 API”

  1. Massimiliano Perelli Says:

    Why do you desire to port the existing code in C++/CLI ? I don’t agree.
    Ciao

  2. Matteo Valdina Says:

    Read with more attention this small article and you should understand that you are wrong.

    Ciao Max :-P

Leave a Reply