-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add script to convert units to a base value. #48
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a better way to differentiate between time conversion and normal unit conversion than what the running script name is.
1) Only one program, use the option --time_val instead of symlink 2) Change options to be --from_unit --to_unit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
We need a tool that given a unit value and value, will convert to another unit. This is required because
Given a unit, convert it to the base.
Time base is nano seconds
Memory base is bytes
There is an existing program, numfmt that provides the units for us, so instead of duplicating each functionality we will leverage it. Also we do not want to duplicate the required logic in every wrapper, so we create a generic script.
To differentiate between time and a 10 based measurement we will symlink a well known script name that is for time. We check $0 on execution of the script if it is the time symlink, then we know we are dealing with time values, and act accordingly.