Jump to content

Can anyone explain this? (why is the i 7 slower)

OutgoingMedusa9

recently i programmed something in VBA  ( i am just starting to learn how to code) and i ran my code on two computers with the same version of windows however the results where not what i was expecting. 

Computer 1: 
Processor: core i5 2 cores 4 logical processors

base clock 2.30GHz
Graphics: intel(530) 
RAM = 8 gb at 2133MHz
Cpu usage = 65%
Gpu usage= 10% 
For 100000 iterations it took 30.30s


Computer 2:  

Processor: core i7 6cores 12 logical processors

base clock 2.20GHz
Graphics: intel(630) 
RAM = 16gb at 2667 MHz
Cpu usage = 10%
Gpu usage= 53%  
For 100000 iterations  i stopped  it at 7 min 

 

can anyone explain why computer 2 is way slower?

 

this is the code

image.png.ba6d853db19f57320dd0113d6723e8d4.png

Link to comment
Share on other sites

Link to post
Share on other sites

It depends on the code you wrote in VBA

Your code is most likely single threaded - only one core will be used to process your script, so the number of cores will not matter. 

 

Maybe on the slower PC you have some debugger or logging enabled by default, which would slow down the code.

It may help to paste your code here and maybe we could even give you some optimization/speedup tips

Link to comment
Share on other sites

Link to post
Share on other sites

Iterations of what?

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, OutgoingMedusa9 said:

recently i programmed something in VBA  ( i am just starting to learn how to code) and i ran my code on two computers with the same version of windows however the results where not what i was expecting. 

Please post your code. We need way more information.

ENCRYPTION IS NOT A CRIME

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, mariushm said:

It depends on the code you wrote in VBA

Your code is most likely single threaded - only one core will be used to process your script, so the number of cores will not matter. 

VBA doesn't support multithreaded. You can although get around it by calling DLL compiled in a language that supports it.

 

2 hours ago, OutgoingMedusa9 said:

 

Computer 1: 
Processor: core i5 2 cores 4 logical processors
Cpu usage = 65%


Computer 2:  

Processor: core i7 6cores 12 logical processors
Cpu usage = 10%

If you were looking at the process CPU usage and not the processor overall average it's easy to determined that computer #2 has issues running the code. Most likely accessing resources that are very active or something as stupid as reading non stop a file on the disk while the anti-virus / windows defender / firewall tries to protect it.

 

Post your code and we can figure that out.

Link to comment
Share on other sites

Link to post
Share on other sites

Windows' scheduler is also such that it if a task pegs a single core a lot, it'll rotate it around to another core. This is done as a potential heat spreading measure. Given that data synchronization latency increases with more cores, one could expect depending on what cores Windows chooses to put the task on, it'll run worse.

 

Though I don't expect it to run that much worse.

Link to comment
Share on other sites

Link to post
Share on other sites

7 hours ago, Franck said:

VBA doesn't support multithreaded. You can although get around it by calling DLL compiled in a language that supports it.

 

If you were looking at the process CPU usage and not the processor overall average it's easy to determined that computer #2 has issues running the code. Most likely accessing resources that are very active or something as stupid as reading non stop a file on the disk while the anti-virus / windows defender / firewall tries to protect it.

 

Post your code and we can figure that out.

i posted the code in the topic, also if it helps i could probably share the file with you? 

image.png

Link to comment
Share on other sites

Link to post
Share on other sites

There are a lot of possible reasons. You didn't even share the model numbers, so it's impossible to know the specs (no, i5 and i7 aren't model numbers), but the main reason is that it's not multi-threaded. It's only using one core.

Make sure to quote or tag me (@JoostinOnline) or I won't see your response!

PSU Tier List  |  The Real Reason Delidding Improves Temperatures"2K" does not mean 2560×1440 

Link to comment
Share on other sites

Link to post
Share on other sites

Zip the file and attach it to a post.

 

Right from the start, you should use Long instead of Single for i, because you don't need single point precision variable for it, as you just increment by 1, round numbers.  Long is 4 bytes so it can hold up to 2 billion, and matches the registers of the cpu (32 bits / 4 bytes) so there shouldn't be data conversions)

You should also narrow the Calculate on a worksheet or range , if possible: https://www.automateexcel.com/vba/calculate-workbook/

initialize i with 0 or something before you go in do ... loop , as best practice, it should be default to 0 anyway...

 

Link to comment
Share on other sites

Link to post
Share on other sites

6 minutes ago, JoostinOnline said:

There are a lot of possible reasons. You didn't even share the model numbers, so it's impossible to know the specs (no, i5 and i7 aren't model numbers), but the main reason is that it's not multi-threaded. It's only using one core.

for the i 5 i would not know i think it is a 7th generation i5  (i dont own that laptop)  for the i7 it is a I7- 8750H 

both are laptop cpu's

 

Link to comment
Share on other sites

Link to post
Share on other sites

First, try this:

// change:
dim i as single
  
// to:
dim i as integer

as @mariushm pointed out.

 

Floating Point performance can be drastically different between different models of processors, even when those processors are in the same generation.

 

Additionally, it's just bad practice to use a floating point number as a sentry value in a loop. We like to think that floating point numbers are able to represent every real number, but they most certainly are not. As a result, a number like 100,000floating point may end up actually being a number like 100,000.0002 or 99,999.9998 and you could logically miss your comparison against 100,000integer . There are also issues with comparing floating point types to integer types in the hardware of the processor itself, which could cause you to miss a comparison between a floating point number and and integer when they should actually be the same. Beyond that, floating point operations are just damned slow: Modern consumer oriented Intel processors processors only offer 30-40 billion floating point operations per second, and somewhere around 1 trillion non-floating-point operations per second.

If i were an integer, and you still have the same performance decrease, then I would venture to guess that it's a configuration problem, as single threaded non-floating-point performance hasn't increased as much over the years as people like to think it has:

  • Are both machines running the same version of VBA?
  • Are both machines running the same version of Excel?
  • Are both machines running in the same performance/power mode?
  • Are both machines using the same version of Windows?
  • Do both machines have enough memory to not cause a bottleneck?

ENCRYPTION IS NOT A CRIME

Link to comment
Share on other sites

Link to post
Share on other sites

Code execution is often regulated by the kernels scheduler. Lots of variables can cause one to perform worse than the other. The windows scheduler on one machine can just decide suddenly windows need an update for example and so it's gonna give 50% of the entire cpu cycle to the updater and starve the other proccesses because you know... Fck the users. 

 

This is one reason I say windows suck. It will download update when it pleases, hogging up cpu, network, disk/ios, and ram and then when you are playing multiplayer games or browsing, it suddenly lags and drop the ping latency to gazillion seconds. Updates aren't cheap. Many windows updates are like gigs in size. You can pretty much figure out the performance impact. 

 

For example in a lowly atom mini PC which I used to stream movie, it will completely freeze. Hours later it will say windows updates fail because it's tiny 32 gigs internal storage is not big enough to handle that update. 

 

Bottom line, windows updates suck. 

 

Sorry I went out of tangent.

Sudo make me a sandwich 

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, Mira Yurizaki said:

Never had a problem with Windows updates.

 

I guess I must be the real Tech Jesus.

That's statistically impossible. You are 99.99999.... 9 repeated to see at least one failed windows update in your life. 

Sudo make me a sandwich 

Link to comment
Share on other sites

Link to post
Share on other sites

14 minutes ago, wasab said:

Code execution is often regulated by the kernels scheduler. Lots of variables can cause one to perform worse than the other. The windows scheduler on one machine can just decide suddenly windows need an update for example and so it's gonna give 50% of the entire cpu cycle to the updater and starve the other proccesses because you know... Fck the users. 

 

This is one reason I say windows suck. It will download update when it pleases, hogging up cpu, network, disk/ios, and ram and then when you are playing multiplayer games or browsing, it suddenly lags and drop the ping latency to gazillion seconds. Updates aren't cheap. Many windows updates are like gigs in size. You can pretty much figure out the performance impact. 

 

For example in a lowly atom mini PC which I used to stream movie, it will completely freeze. Hours later it will say windows updates fail because it's tiny 32 gigs internal storage is not big enough to handle that update. 

 

Bottom line, windows updates suck. 

 

Sorry I went out of tangent.

I'll admit, I have my fair share of gripes with Windows. But I've got some gripes with Linux too (hence why I use FreeBSD every time I think about using Linux)

But in 25 years of using various versions of Windows, I have never experienced the type of behavior you describe, excluding Vista. As far as performance hogging goes, I occasionally experience an interrupt storm from File Explorer, but that's only because I have it configured to automatically index my main working drive periodically so that I can have increased file system search performance.

I guess YMMV as this tangent would suggest.

ENCRYPTION IS NOT A CRIME

Link to comment
Share on other sites

Link to post
Share on other sites

10 minutes ago, straight_stewie said:

I'll admit, I have my fair share of gripes with Windows. But I've got some gripes with Linux too (hence why I use FreeBSD every time I think about using Linux)

But in 25 years of using various versions of Windows, I have never experienced the type of behavior you describe, excluding Vista. As far as performance hogging goes, I occasionally experience an interrupt storm from File Explorer, but that's only because I have it configured to automatically index my main working drive periodically so that I can have increased file system search performance.

I guess YMMV as this tangent would suggest.

Thats because you werent playing intensive multiplayer games or steaming 4k movies when it happened. 

Sudo make me a sandwich 

Link to comment
Share on other sites

Link to post
Share on other sites

56 minutes ago, wasab said:

Thats because you werent playing intensive multiplayer games or steaming 4k movies when it happened. 

And just how might you know my usage patterns?

ENCRYPTION IS NOT A CRIME

Link to comment
Share on other sites

Link to post
Share on other sites

43 minutes ago, straight_stewie said:

And just how might you know my usage patterns?

Why don't you set up a lab and test it if you don't believe me? Windows updates will slow things down, especially if Windows defender is also firing up in the background scanning all the data windows update are downloading. It is not even a matter of opinion.

Sudo make me a sandwich 

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, wasab said:

Why don't you set up a lab and test it if you don't believe me? Windows updates will slow things down, especially if Windows defender is also firing up in the background scanning all the data windows update are downloading. It is not even a matter of opinion.

I've yet to see this behavior.

 

Must be user error.

 

Or again, I'm the real Tech Jesus.

Link to comment
Share on other sites

Link to post
Share on other sites

10 minutes ago, Mira Yurizaki said:

I've yet to see this behavior.

 

Must be user error.

 

Or again, I'm the real Tech Jesus.

Why don't you go set up the computers and do benchmarks to test it out like I suggested? Not that difficult if you got an outdated windows 10 disk you know. 

Sudo make me a sandwich 

Link to comment
Share on other sites

Link to post
Share on other sites

10 minutes ago, wasab said:

Why don't you go set up the computers and do benchmarks to test it out like I suggested? Not that difficult if you got an outdated windows 10 disk you know. 

If you're stressing the system, anything else that wants the system is going to affect the results. You may as well tell me that running RDR2 at the same time as 3DMark is making your 3DMark scores suffer.

 

But as far as this use case goes?

4 hours ago, wasab said:

Thats because you werent playing intensive multiplayer games or steaming 4k movies when it happened. 

Nah, and I play an MMO regularly

Link to comment
Share on other sites

Link to post
Share on other sites

11 hours ago, straight_stewie said:

As a result, a number like 100,000floating point may end up actually being a number like 100,000.0002 or 99,999.9998 and you could logically miss your comparison against 100,000integer

That's the most likely option. The fact it took so much longer on the second system and it had to be aborted supports the view that it missed the 100000 mark. 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×