Example:
> time { for($e=0; ; ++$e) { if ($e -ge 1000) { break } } }
TotalMilliseconds : 10.8296
> time { for($e=0; ; ++$e) { if ($e -ge 1000) { break } else {
> continue } } }
TotalMilliseconds : 170.6035
Can anybody repro\confirm this?
--
Thanks,
Roman Kuzmin
Yes, it's about 20x slower for me too. Is continue an expensive
statement in other languages too such as C++? Can't say I've ever
noticed it. Does Powershell compile script blocks down to IL? I
guess you've maybe got anther script-block around the continue that
needs to be entered into, unless it's optimized away?
function time
{
[datetime]$startTime = [datetime]::now
for($e=0; ; ++$e)
{
if ($e -ge 1000)
{
break
}
}
[datetime]$endTime = [datetime]::now
($endTime - $startTime).TotalSeconds
}
function time2
{
[datetime]$startTime = [datetime]::now
for($e=0; ; ++$e)
{
if ($e -ge 1000)
{
break
}
else
{
continue
}
}
[datetime]$endTime = [datetime]::now
($endTime - $startTime).TotalSeconds
}
0.01 v 0.2
-- Ryan Milligan
"Duncan Smith" <DSmit...@googlemail.com> wrote in message
news:1175712048....@l77g2000hsb.googlegroups.com...
--
Thanks,
Roman Kuzmin
Certainly makes a good deal of sense, well found!
This reflector tool looks extremely useful, this will get a lot of
usage from me - kind of like having the MFC code to browse through.
I see that you can search for 'continue' and it finds
ContinueException in system.management.automation, but how did you
then find a reference to that tucked away in the FlowControl.Execute
method? I can't see a way to search all of the disassembled code?
Do you think there's a way that you could debug into the code that
reflector shows? Maybe by inserting a 'stop' command in a .ps1 file
(or whatever the powershell equivalent of an _asm int 3; breakpoint
call is) and then hooking it up to an instance of VS2005 for a debug
session?
Many thanks,
Duncan
As for debugging the code generated by Reflector, I've thought about this
myself many times. Basically, you'd need to write an extension to Reflector
that would generate a folder of source code, and a .pdb file from the .dll
that maps offsets in the IL to lines in the generated source code. I haven't
looked to see if the Reflector API provides access to all the information
you would need, but I suspect that it might. Maybe I'll get around to
looking into it some time.
-- Ryan Milligan
"Duncan Smith" <DSmit...@googlemail.com> wrote in message
news:1175849380.9...@w1g2000hsg.googlegroups.com...