Follow the code I have to check the performance
double a = r.Next(9)*1e307 ;
DateTime d = DateTime.Now;
double b = Math.Pow(a,1/(double)100);
TimeSpan tm = DateTime.Now - d;
Console.WriteLi ne("{0}---{1}",b,tm.Ticks );
The return value is 0 Ticks - IT CAN NOT BE !!! What is the problem?
--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us " 16 1687
Tamir Khason <ta**********@t con-NOSPAM.co.il> wrote: Follow the code I have to check the performance double a = r.Next(9)*1e307 ;
DateTime d = DateTime.Now;
double b = Math.Pow(a,1/(double)100);
TimeSpan tm = DateTime.Now - d;
Console.WriteLi ne("{0}---{1}",b,tm.Ticks );
The return value is 0 Ticks - IT CAN NOT BE !!! What is the problem?
The problem is that it's taking less time than the granularity of the
timer. Do the operation a million times, time that, and then divide by
a million.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Thank you this works, however how it is possible to count such small
operations without multiplexing them?
--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com... Tamir Khason <ta**********@t con-NOSPAM.co.il> wrote: Follow the code I have to check the performance double a = r.Next(9)*1e307 ;
DateTime d = DateTime.Now;
double b = Math.Pow(a,1/(double)100);
TimeSpan tm = DateTime.Now - d;
Console.WriteLi ne("{0}---{1}",b,tm.Ticks );
The return value is 0 Ticks - IT CAN NOT BE !!! What is the problem?
The problem is that it's taking less time than the granularity of the timer. Do the operation a million times, time that, and then divide by a million.
-- Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
Tamir Khason <ta**********@t con-NOSPAM.co.il> wrote: Thank you this works, however how it is possible to count such small operations without multiplexing them?
Well, there's the high resolution performance counter, documented in
various places (I don't have a link to hand) - but to be honest, that's
going to be influenced significantly by other things, such as what else
is happening on the computer at the time. Timing a single very fast
operation is generally a bad idea.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Thank you ;) But this what the client wants ;)
--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com... Tamir Khason <ta**********@t con-NOSPAM.co.il> wrote: Thank you this works, however how it is possible to count such small operations without multiplexing them?
Well, there's the high resolution performance counter, documented in various places (I don't have a link to hand) - but to be honest, that's going to be influenced significantly by other things, such as what else is happening on the computer at the time. Timing a single very fast operation is generally a bad idea.
-- Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
Accumulating a million measures and than dividing by million will give an
average time of the operation - which is much more meaningful from my point
of view.
Otherwise, using the high-resolution timer is the only option, but the
results will indeed vary depending on CPU usage. The reason is quite
simple - Windows is not a real-time OS by design.
--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today! http://www.x-unity.net/teststudio.aspx
"Tamir Khason" <ta**********@t con-NOSPAM.co.il> wrote in message
news:uO******** ******@TK2MSFTN GP14.phx.gbl... Thank you ;) But this what the client wants ;)
-- Tamir Khason You want dot.NET? Just ask: "Please, www.dotnet.us "
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message news:MP******** *************** *@msnews.micros oft.com... Tamir Khason <ta**********@t con-NOSPAM.co.il> wrote: Thank you this works, however how it is possible to count such small operations without multiplexing them?
Well, there's the high resolution performance counter, documented in various places (I don't have a link to hand) - but to be honest, that's going to be influenced significantly by other things, such as what else is happening on the computer at the time. Timing a single very fast operation is generally a bad idea.
-- Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
That's the point. My client want to make benchmark of simplest math
calculations on vary platforms. Thus the solution of accumulation is not
suitable for him. I begun to override win32 and kernel for those
calculations. Maybe there is better approach...
--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.c om> wrote
in message news:eD******** ******@TK2MSFTN GP15.phx.gbl... Accumulating a million measures and than dividing by million will give an average time of the operation - which is much more meaningful from my point of view. Otherwise, using the high-resolution timer is the only option, but the results will indeed vary depending on CPU usage. The reason is quite simple - Windows is not a real-time OS by design.
-- Sincerely, Dmitriy Lapshin [C# / .NET MVP] Bring the power of unit testing to the VS .NET IDE today! http://www.x-unity.net/teststudio.aspx
"Tamir Khason" <ta**********@t con-NOSPAM.co.il> wrote in message news:uO******** ******@TK2MSFTN GP14.phx.gbl... Thank you ;) But this what the client wants ;)
-- Tamir Khason You want dot.NET? Just ask: "Please, www.dotnet.us "
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message news:MP******** *************** *@msnews.micros oft.com... Tamir Khason <ta**********@t con-NOSPAM.co.il> wrote: Thank you this works, however how it is possible to count such small operations without multiplexing them?
Well, there's the high resolution performance counter, documented in various places (I don't have a link to hand) - but to be honest, that's going to be influenced significantly by other things, such as what else is happening on the computer at the time. Timing a single very fast operation is generally a bad idea.
-- Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
Tamir,
In that case, I think you need to have a face to face with your client
about the nature of the OS, processors, and why this isn't feasible.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Tamir Khason" <ta**********@t con-NOSPAM.co.il> wrote in message
news:OI******** ******@TK2MSFTN GP11.phx.gbl... That's the point. My client want to make benchmark of simplest math calculations on vary platforms. Thus the solution of accumulation is not suitable for him. I begun to override win32 and kernel for those calculations. Maybe there is better approach...
-- Tamir Khason You want dot.NET? Just ask: "Please, www.dotnet.us "
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.c om> wrote in message news:eD******** ******@TK2MSFTN GP15.phx.gbl... Accumulating a million measures and than dividing by million will give an average time of the operation - which is much more meaningful from my point of view. Otherwise, using the high-resolution timer is the only option, but the results will indeed vary depending on CPU usage. The reason is quite simple - Windows is not a real-time OS by design.
-- Sincerely, Dmitriy Lapshin [C# / .NET MVP] Bring the power of unit testing to the VS .NET IDE today! http://www.x-unity.net/teststudio.aspx
"Tamir Khason" <ta**********@t con-NOSPAM.co.il> wrote in message news:uO******** ******@TK2MSFTN GP14.phx.gbl... Thank you ;) But this what the client wants ;)
-- Tamir Khason You want dot.NET? Just ask: "Please, www.dotnet.us "
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message news:MP******** *************** *@msnews.micros oft.com... Tamir Khason <ta**********@t con-NOSPAM.co.il> wrote: > Thank you this works, however how it is possible to count such small > operations without multiplexing them?
Well, there's the high resolution performance counter, documented in various places (I don't have a link to hand) - but to be honest, that's going to be influenced significantly by other things, such as what else is happening on the computer at the time. Timing a single very fast operation is generally a bad idea.
-- Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
By the way, Jon Skeet is correct: timing a single short operation produces
meaningless data. You must loop in an operation that takes a few 10s of
milliseconds, minimum, to obtain anything useful, and even that is fairly
meaningless unless your CPU is running a single process (impossible). So
plan on looping a thousand times for your little operation, and then loop
that loop 10 or 20 times, getting the elapsed time each time, then look at
the average of those times, possibly excluding the first loop.
At least the performance counter does produce accurate data. TimeSpan is not
accurate.
Regards,
Frank Hileman
check out VG.net: http://www.vgdotnet.com
Animated vector graphics system
Integrated Visual Studio .NET graphics editor
"Tamir Khason" <ta**********@t con-NOSPAM.co.il> wrote in message
news:e9******** ******@tk2msftn gp13.phx.gbl... Follow the code I have to check the performance double a = r.Next(9)*1e307 ;
DateTime d = DateTime.Now;
double b = Math.Pow(a,1/(double)100);
TimeSpan tm = DateTime.Now - d;
Console.WriteLi ne("{0}---{1}",b,tm.Ticks );
The return value is 0 Ticks - IT CAN NOT BE !!! What is the problem?
-- Tamir Khason You want dot.NET? Just ask: "Please, www.dotnet.us "
Frank,
The performance counter doesn't either produce accurate data, the
granularity of the high performance timer is still an issue when timing
short operations.
Willy.
"Frank Hileman" <fr******@no.sp amming.prodiges oftware.com> wrote in message
news:OU******** ******@TK2MSFTN GP10.phx.gbl... By the way, Jon Skeet is correct: timing a single short operation produces meaningless data. You must loop in an operation that takes a few 10s of milliseconds, minimum, to obtain anything useful, and even that is fairly meaningless unless your CPU is running a single process (impossible). So plan on looping a thousand times for your little operation, and then loop that loop 10 or 20 times, getting the elapsed time each time, then look at the average of those times, possibly excluding the first loop.
At least the performance counter does produce accurate data. TimeSpan is not accurate.
Regards, Frank Hileman
check out VG.net: http://www.vgdotnet.com Animated vector graphics system Integrated Visual Studio .NET graphics editor
"Tamir Khason" <ta**********@t con-NOSPAM.co.il> wrote in message news:e9******** ******@tk2msftn gp13.phx.gbl... Follow the code I have to check the performance double a = r.Next(9)*1e307 ;
DateTime d = DateTime.Now;
double b = Math.Pow(a,1/(double)100);
TimeSpan tm = DateTime.Now - d;
Console.WriteLi ne("{0}---{1}",b,tm.Ticks );
The return value is 0 Ticks - IT CAN NOT BE !!! What is the problem?
-- Tamir Khason You want dot.NET? Just ask: "Please, www.dotnet.us "
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Keith Langer |
last post by:
I would like to know why locking on a new object takes significantly
longer than locking on a strongly typed object. All of the posts I've
seen say that it is best to lock on a "new object", but it takes more
than 3x longer than locking on anything other than object. Here's a
test case:
Module Module1
Sub Main()
|
by: Gustavo L. Fabro |
last post by:
Greetings!
Getting straight to the point, here are the results
of my experiment. I've included my comments and questions
after them.
The timing:
(The total time means the sum of each line's drawing time.
Time is measured in clock ticks (from QueryPerformanceCounter() API).
The processor resolution (QueryPerformanceFrequency()) for my
|
by: Alex Vinokur |
last post by:
For instance, we need to measure performance
of assignment 'ch1 = ch2' where ch1 and ch2 are of char type.
We need to do that for different optimization levels of the same compiler.
Here is some test program.
Environment
-----------
|
by: Jojo |
last post by:
Is there any way to get to the left-hand side of an operator? Consider
the following (this is not meant to be perfect code, just an example of
the problem):
class Matrix
{
public:
int data;
Matrix() {}
|
by: Anders Both |
last post by:
In my application the fowing call:
workSocket.BeginSend(byteData, 0, byteData.Length,0, new
AsyncCallback(SendMesCallBack), null);
Takes between 156250 and 312500 Ticks . And when like 20 calls are made at a
time, they really sum up to something that I did not exspect att all.
Why does I exspirence this thing, is this normal ?
(I am 100% sure that the time is consumed by only this single line)
| |
by: James Radke |
last post by:
Hello,
I am creating an owner draw listbox for a windows application. It is all
working, except the performance is significantly slower than the standard
listbox. Basically what I have done is added two new properties (full
source below):
ChangeBackgroundMember = a bound data field which contains a boolean as
to whether this record should get a special background color
ChangeBackgroundColor = the color to use when the above...
|
by: NormD |
last post by:
I've been told that how one does a loop in VB .NET cna have significant speed
differernces. For example:
dim therows() as datarow
.....
dim row as datarow
for each row in therows
.....
next row
|
by: Alex Chudnovsky |
last post by:
I have come across with what appears to be a significant performance bug in
..NET 2.0 ArrayList.Sort method when compared with Array.Sort on the same
data. Same data on the same CPU gets sorted a lot faster with both methods
using .NET 1.1, that's why I am pretty sure its a (rather serious) bug. Below
you can find C# test case that should allow you to reproduce this error, to
run it you will need to put 2 data files into current directory...
|
by: ian.smith |
last post by:
I have a small sellection of code here. When the "button1_Click" is
called the performance is quite poor (~ 0.5 sec). Only thing is I am
not really doing anything!! In C++ the same thing takes ~ 0 seconds to
execute!!. The List<Pumpicle> is faster than ArrayList and I convert
the List to an array before access. It just seems to be something like
unboxing the doubles out of the Pumpicle class. Any ideas??
PumpicleContainer pc = null;
...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |