This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The reason your script isn't functioning as expected is that the `start-job` cmdlet spins off a new background job for each logical processor on your machine. However, there's no wait command for these jobs to finish, and thus the script just runs to completion without waiting for these CPU-intensive tasks to finish. Then it calls `Stop-Job *`, which kills any running background jobs, likely before they've had a chance to start. | |
Moreover, the nested loops in your script are potentially creating an exceedingly large number of iterations. If you're trying to generate CPU load, you don't need that much looping; a smaller, but still large, number of iterations would be sufficient. | |
Also, keep in mind that your jobs are using the same variable names for their loop counters (`$loopnumber` and `$loopnumber1`). This might not cause an issue, but it can lead to confusion and potential bugs. It's a best practice to use unique, descriptive variable names. | |
Here's an example of how you could revise your script: | |
```powe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am joshuamkite on github. | |
* I am joshuamkite (https://keybase.io/joshuamkite) on keybase. | |
* I have a public key ASAmacZg9CZA38yhf_6eo3W-W6VOxUvMzKQj1No2rkaddAo | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Print integers 1 to 100, but print “Fizz” if an integer is divisible by 3, “Buzz” if an integer is divisible by 5, and “FizzBuzz” if an integer is divisible by both 3 and 5. | |
// This implementation populate our integers using a for loop and uses nested if statements but by using boolean evaluations at the start of our evaluation loop we perform each modulus evaluation ony once | |
package main | |
import "fmt" | |
func main() { | |
n := []int{} |