|
For pmj
Sun, 15 Oct 2006 14:08:09 +0100
uk.people.silversurfers
previous
Jeff Gaines...
|
This is from KNode using Mandriva in a Parallels VM.
I'm getting bounce on the keyboard.
Jeff Gaines...
|
And a reply from KNode using Debian in Virtual PC 2007 beta.
pmj...
|
Great!!!
:-)
I dunno why you're getting "bounce" on the Keyboard.
:-(
How do you find that Parallels compares to the M$ Virtual PC 2007 ?
& have you tried VMWare yet?
I have only tried Parallels & VMWare & M$ Virtual PC2004 (not the
M$ VPC 2007 Beta one)
Have you run any of the various "Benchmarking" type Utilities to
see how well they compare, running a Virtual Machine (using proper
Hardware Virtualization, rather than the earlier Emulation) compared
to running the same things directly on your PC, now that you have
a fancy Intel Core 2 Duo Processor & loads of Sheep in your PC?
I wrote a little Script that runs in a Web Browser, that does
2 (very tight) Loops, one within the other & it virtually Locks
up a single Core Processor (it shows as using nearly 90 - 100 %
of the CPU, on a single Core Processor) - it counts to 10,000 &
for each Number, it divides it by 2 (if it's an even Number) or
multiplies it by 3 & adds one (if it's an odd Number) until the
Number becomes 1...
That makes it Loop round & round in a very haphazard, chaotic (but
not random!) way, sometimes (depending on the Number) for just a few
Loops & other times for over 100 Loops on each Number.
On my PC, (which has a 3.4 GHz Pentium 4 HyperThreading Processor)
it takes about 40 Seconds to go through all 10,000 Numbers, (using
just one "half" (about 49 - 52 %) of the Processor) but when I run
it in a Parallels Virtual Machine (on the same PC), it takes nearly
60 Seconds to Run (but it uses all (or about 90 %) of the Processor
that the Parallels Virtual Machine sees) - it seems that Parallels
only lets the Virtual Machine see one of the Cores of a Dual Processor?
- Unless it treats a HyperThreading Processor differently from the
way it would handle a *Real* Dual Core Processor.
If you (or anybody else who wants to test their Processor) want
to try this Script that I wrote out, Post back & I will include it
in a Reply - it's only about a Dozen Lines long (plus another half
dozen Lines to Display the (elapsed) Time that it takes, from start
to finish).
Jeff Gaines...
|
I will do some testing at some point but I am trying to sub-class a
ListView ATM and it's doing my head in :-)
I would be interested in the script, you can email it if you prefer.
pmj...
|
Well, try this for a little "light relief" then?...
Jeff Gaines...
hail.htm
Just Copy & Paste that into a Plain Text File & Save it as (for example)
hail.htm, then Run (Open) it.
Jeff Gaines...
|
Tried that, run it several times but it doesn't seem to finish. Is it
pmj...
|
Oh!
It takes about 40 Seconds on my 3.4 GHz HyperThreading Pentium 4
& in a (Parallels) Virtual Machine (which only seems to show up one
Core) it takes about 60 Seconds.
& I tried it on an (unwilling!) [*1] accomplice's Machine, which
is a 2.6? GHz (Non-HyperThreading) Pentium 4 & it took about 80 Seconds
(but that was cos her Internet Explorer kept Popping up the Dialog Box
saying "A Script on this Page is using a lot of Processing Power, do you
want to Abort the Script?) & she had to keep Clicking [No], to let it
Run & finish.)
[*1]
The "accomplice" (assistant - "testee/tester"?) was a bit short of time,
(it was nearly MidNight) so wasn't able to help with more "in-depth"
testing.
|
guaranteed to always finish?
pmj...
|
Well, yes, it *should* do!
If you look at the 2 Loops in it, one (the Outer one) is a Loop
Counting to 10,000...
Number=0;
while(Number++<10000){
...
}
& then, within that Loop (for each (& every) Number between 1 & 10,000),
it then assigns that Value to a variable called "NextNumber" & enters an
Inner Loop
while(NextNumber>1){
...
}
& looks at it & then (if it's an even Number) Divides it by 2 or
(if it's an odd Number) Multiplies it by 3 & then adds 1 to it
& then assigns that Value to the variable NextNumber & does it all
again (& again & again... - until the NextNumber becomes 1)...
That means that *eventually* (for any starting Number), the
(Next)Number becomes (decays back to?) 1, but some Numbers
(such as 27) take over 100 Passes to become (decay back to?) 1
*All* numbers do eventually become 1, when that Algorithm is applied.
NextNumber=NextNumber%2==0?NextNumber/2:NextNumber*3+1;
That's, basically the same as:
if (NextNumber % 2 == 0){
NextNumber = NextNumber / 2
}
else {
NextNumber = NextNumber * 3 + 1
}
Both Loops do have a (clearly defined) Exit Condition, so I dunno why
it didn't finish on your Machine.
In Internet Explorer, it seems to only Output anything at the end
(rather than UpDating the Display in the Browser Window while it's
Running)
You could try putting in that Line I mentioned?...
window.status="Number: "+Number+" Count: "+Count;
Bung it in before the last Closing Curly Bracket - That does at
least Update the StatusBar at the bottom of the Browser, each time
round the (Outer) Loop, so you can see what Number it's at - that
should (rapidly) go up from 1 to 10,000, showing the Count of
iterations of the Inner Loop that it's done - but bear in mind
that if you switch the Focus away from the Window, it may not
UpDate the StatusBar.
|
|
I'm not sure how well it works (if at all) in any other Web Browser
than Internet Explorer. In a Single Processor System, IE Pops up a
Dialog Box saying something like "A Script Running on the Page is
causing the Browser to Run Slowly" (i.e. it's taking up a lot of
Processor Cycles), but on a Dual Core (or HyperThreading) Processor,
you don't get that.
Jeff Gaines...
|
I do, every time :-)
pmj...
|
Weird!!!
I know that there's also a Registry Value that you can Set, to say
how many Iterations of a (tight) Loop, such as those ones are, that
it will allow, before it chucks up that Message/Dialog Box, but I
haven't Set that on my PC - it is Set at the Default.
|
I paste it into a new C# program, had to tweak it slightly but not much.
Started it, it was still running after an hour. Took the dog for a walk
(an hour), still running when I got back. CPU temp up by 5 degrees, CPU
pmj...
|
Yep - that's cos it's using pretty much all of (just one) Core of
the Processor. (the 2 Loops are very tight, with just the Test
Condition & the Multiplication/Division in them).
|
usage at 50%.
Should I stop it?
pmj...
Jeff Gaines...
|
It's useful ATM, I put some quiet fans on today and I wanted to see how
they coped! The CPU temp is hovering around 47 degrees which I think is OK.
|
Jeff Gaines...
|
Yes, I'm using integers. My maths isn't good enough to work out if it
pmj...
|
& taht thing just divides by 2 (if the Number is even) or Multiplies
by 3 & adds 1 (if the Number is odd), so it only actually needs whole
Numbrs (Integers?) so it can can work perfectly well using Integers
& it doen't then pass a (non-integer) value on to be (possibly) wrongly
worked out or get involved in "Rounding Errors".
Ali...
|
Yes, it works perfectly using integers (that is, a method of representing
numbers that can *only* represent whole numbers).
It should also work perfectly using floating point numbers (that is, a
method of representing numbers that can represent a wide range of
fractional numbers as well as whole numbers).
However the representation of a whole number in floating point form *can*
acquire rounding errors, since, for example point 9 recurring is an
integer (one), as is one point zero recurring. When truncated to any
finite length an error occurs.
|
|
pmj...
|
It's definitely *not* Random, at all. - yes, it's a bit "Chaotic" -
in as much as one Number (such as 2 4 8 16 32 & 64 etc, - Powers of 2)
may Loop (on the Inner Loop) only a few times - just being divided by
2 each time) but other Numbers (such as 27(!?) take 111 Steps before
they get down to Zero (having been through several stages of being
Multiplied by 3 & having 1 added to them)
Ali...
|
No number (except zero) will get down to zero using that algorithm. :^)
2 to the power n will rapidly reduce to 1, in n steps.
3 to the power n (such as 27) will *increase* (by multiplying by 3, adding
1, and dividing by 2) in at least 2n steps, and decrease by additional
halving, until a power of 2 is reached.
|
It *always* follows exactly the same path - for any Number there is
one (& one only) sequence for it to follow.
So, there's actually scope for some clever "Predictive branching"
possibly?
If the (internal) CPU stuff was clever enough, it *ought* to be able
to say to itself (when it hits ceratin Numbers "Hey, I came across
this sequence just now & I know what steps to take, so I'll just copy
the same results", sort of thing.
Ali...
|
Yes, whenever an inner sequence reaches a number already used in the outer
loop, the result is already known. However to make use of this, the
results would have to be stored; no CPU optimiser is going to do this; a
program optimiser might.
|
|
should always follow the same path of if there is a variety of possible
outcomes!
|
pmj...
|
That's up to you!!!
You can if you want!!!
:-)
You could also try changing the Outer Loop, so it only does the
Numbers up to 1,000 (or even just 100?) - I wouldn't advise changing
it to *more* than 10,000 though!
Cos it takes up about 60 MB of Memory as it stands .
BTW - I just tried it using an Outer Loop Limit of 100,000(!) & it
took just over 1,208 Seconds (about 20 Minutes!) & used up about
700 MB of Memory [*2] Some of the Inner Loops were taking nearly
200 iterations to get back to 1
& with an Outer Loop of just 1,000 it only took 3.203 Seconds
& used up only about 10 MB of Memory.
[*2]
I also just tried it again with an Outer Loop of 100,000(!), but
this time without any of the "document.write(...)" bits inside
the Loop(s) - while still doing the Division & Multiplication for
each Number.
That means that I.E. didn't have to allocate Time (& Memory) to
trying to do the Display stuff, (but it still uses the Processor
a lot) & this time the 100,000(!) Loop only took 26.938 Seconds
:-)
& it used less than 10 MB of Memory.
I dunno why your fancy new MotherBoard & Intel Core 2 Duo Processor
seems to be having trouble with it.
Jeff Gaines...
|
I do, but I will blame it on the lack of logic in Windows. When the script
starts I got a pop up saying do you want to run this ActiveX control, I
pmj...
|
Well, it's *not* actually an "ActiveX" Control - but it *is* an
"Active Script" (JScript) thingy.
|
click Yes and off it goes. Then the 'do you want to continue' dialog pop
up, but with yes and no reversed, so I was clicking no :-(
pmj...
|
Ah!
That would explain it then, prolly?
But I'm still a bit puzzled as to why your Version of IE/windoze
Pops up that Dialog Box - cos with a Dual Core Processor, it
*shouldn't* actually Lock the thing up. (& doesn't on mine)
Jeff Gaines...
|
It doesn't lock up, I suspect there's not much s/w about that's dual
processor aware, there certainly wasn't last time I had a dual processor PC.
pmj...
|
No, but the *Operating* System is Dual Core (Processor) aware, isn't it?
& it will Run something like that on one Core (or Processor), while
the rest of the Operating System still runs OK, using the other Core
(or Processor) so the System (as a whole) doesn't Slow down, when
something like taht Script (with its very tight Loops) is Running.
|
|
|
So here are the results:
Run 1 - running the script with the C# program also running:
36 seconds, 100% processor time, CPU temp up to 52!
pmj...
|
36 Seconds? - For the 10,000 (Outer) Loop?
That seems about right - though oddly enough, that's not much faster
than mine, which isn't actually a Dual Core Processor - it's just
a HyperThreading one (though mine is the earlier sort of Pentium
& runs at 3.4 GHz)
& notice that even when the C# Proogram was running at the same time,
it still ran the script fast enough (I assume cos the C# Program was
running on the other Core)?
|
Run 2 - after closing the C# app:
33 seconds, 50% CPU time.
pmj...
|
Not much increase then (less than 10 %) ? That's prolly to be expected,
since it was running on a different (separate) Core.
|
Run 3 - taking out the line which updates the status bar:
26.6 seconds, CPU time 30%-50%.
pmj...
|
Again, the Updating of the StatusBar is something which *must* take
some time, but I think it's the "document.write(...)" stuff in (both)
the Loops that takes the real time (& also uses a lot of Memory)
I tried it without those "document.write(...)" bits in the Loops
(just leaving in the startTime, endTime & elapsedTime ones (at the
beginning & end) *outside* the Loops) & I found that it ran an
Outer Loop of 100,000(!) in about 26 Seconds.
:-)
Now, can you try it using one of your Virtual Machines?
Either Parallels, M$ VPC 2007 or VMWare?
& see how that affects it?
Jeff Gaines...
|
When I get a mo, will it run under Linux?
pmj...
|
Hmmm...
Good point!!!
Yes, I *think* it will!!!
It's just a J(ava)Script - so anything that can Run J(ava)Script
should be able to Run it OK - most other Web Browsers in use (whatever
the Platform/Operating System will Run J(ava)Script.
But you may find that some of the particular Constructs/Syntax that
I used may be wrong for other Versions & you may need to put in the
rest of the "Page" round it (you might need a Tag & also a
Tag as well & have them both in a Tag like this...
Test Loop Script
|
|
|
I'll have a play with the C# app, I've probably misinterpreted something,
it would make a good basis for a multi threaded test app.
pmj...
|
Yep, 10,000 separate Threads?
:-)
Jeff Gaines...
|
It took 40 minutes to run with a seed of 40. If that's C# overhead it's a
pmj...
|
I dunno much about that, sorry.
BTW - I've been trying it out (with up to 1,000,000 in the outer Loop!)
But I found that with much more than 10,000 it took a long time if I
left in the "document.write(...)" bits - without them (just commenting
them out) it ran *very* much faster (while still using half the
Processor - one Core/Thread) - it took 23.188 Seconds for 100,000
Loops of it.
|
bit frightening...
|
Each one can then handle just the Looping back to 1 (Dividing by 2
or Multiplying by 3 & adding 1)
:-)
|
|
I'd be interested to hear from anybody else how their Machine handles
it (& what Processor/MotherBoard & RAM they have - it's obviously seems
to be a fairly heavy test of the Processor (& to a lesser extent of
the RAM).
|
|
& also (depending on the Security Settings in the Web Browser) it
may say something about "Do you wish to allow this Script to Run"
It takes about 40 Seconds on my 3.4GHz Pentium 4 HyperThreading
Processor. I can't (at the moment) get it to Update the Display while
it's Running (it just shows nothing until it's finished, then fills
the Browser with a load of stuff (the Counting) & shows the elapsed
Time taken to Run it)
|
|
|
Bram...
|
Last time I looked at the Debian site there was 15 CD images.
Did you download them all..?
Jeff Gaines...
|
No, I bought a CD/DVD set!!!
Bram...
|
I'm gonna try it when I've got some time on my hands.
I've tried a few different distros based on Debian. Demolinux, Knoppix,
Ubuntu, Kubuntu and Mepis but I've never tried Debian itself.
Tickettyboo...
|
Aren't they the names of the not terribly well known , but extremely
jolly, Santa's Sheep ? aint well> :-)
datasmog...
|
Nah. They're mountains. You can do a coach tour round all of them. Takes
a couple of weeks and you get a free tent a pair of hiking boots and
dysentery.
|
|
I'm gonna download the whole caboodle I think.
|
|
|
|
|
next
|