-
Notifications
You must be signed in to change notification settings - Fork 624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
factor 50 #55
Comments
Good morning, some ideas to write a standalone utility which could emulate GNU factor command when not available.
|
Try your code with the number from my benchmark :) |
Alright, it's not ideal. Let's rethink. With bash arithmetic, I can't handle numbers as large as those accepted by the factor command, no bignum support, bound to intmax_t. But second take on a fast factorize placeholder routine (not bad):
We certainly could tweak more, like splitting strategies, however, one can write a fair placeholder, bash rumbling day. (Prime factors is an addictive topic). |
factor is not a bash built-in nor a bash plugin. It's a program in its own right, independent of bash, part of gnu coreutils, and is related to bash about as much as, say, a video- or music player is.
busybox provides a factor app too, alas it's much more limited in allowable number range than the coreutils version, which I tend to use as quick poor person's CPU benchmark:
time factor 1234567890123456789012345678901
As this yields two large prime factors, it takes a reasonable (as in measurable) time. Because the number is easy to memorize, and can be shortcut nicely with copy-and-paste, it serves as a nice rough evaluation of CPU performance - depending on machine between about 150ms for notebooks and desktop computers, to 400 to 1000 and above ms for ARM SBC. My WiFi router takes about 4 seconds, comparable to oldish ARM SBCs.
Nevertheless, factor still isn't related to bash.
The text was updated successfully, but these errors were encountered: