-
Notifications
You must be signed in to change notification settings - Fork 12
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
Feature request - only read specific sections of ini file #9
Comments
Absolutely - if this project is seeing this much attention, I'll happily spend the time trying to optimise it! As soon as possible, I'll investigate general optimisations (to increase the speed overall) and, as you suggest, a specific enhancement to deal with only the section in question. |
Thank you very much. We have included your "Shini" script in our small free audio player for Raspberry - the piCorePlayer: https://sites.google.com/site/picoreplayer/home |
That's really cool :-) May I ask for an example copy of the INI file you're parsing, and an example of the operation(s) you're performing on it? I've made some fairly aggressive changes for Regarding processing a specific section, am I understanding correctly that you'd like to be able to specify |
I've included PHP's shipped The overall performance increase is very significant with the earlier changes: Before
After
(Note, Including specifying the section, further gains can be made:
|
This is great :-)
Here is a sample DAC.conf file
Please note that we are using ash #!/bin/sh as we are building on piCore which is using busybox |
Yes we would like to be able to only parse a specific part of the ini file (for other parts of our player) - so your additions are highly appreciated. |
Sorry - but the new shini script do not run on our system.
If I change it to this it runs, but ..:
|
Ah, I've not tested t under ash. Which version specifically are you using? I'll see if I can fix the incompatibility. |
Ok. Could you let me know you shell version? (Specifically the shell version the script is being ran under.)
…Sent from my iPhone
On 6 May 2017, at 13:43, amtssp ***@***.***> wrote:
Sorry - but the new shini script do wont run on our system.
This function stalls it all:
shini_regex_replace()
{
if [ "${BASH_VERSINFO}" -ge 3 ] || [ -n "$ZSH_VERSION" ]; then
[[ "$1" =~ $2 ]] && shini_retval=${BASH_REMATCH[1]} || shini_retval="$1"
return 0
fi
shini_retval="$(printf '%s' "$1" | sed -E "s/$2/\1/")" # If you have isses on older systems,
# it may be the non-newer POSIX compliant sed.
# -E should be enabling extended regex mode portably.
}
If I change it to this it runs, but ..:
shini_regex_replace()
{
# if [ "${BASH_VERSINFO}" -ge 3 ] || [ -n "$ZSH_VERSION" ]; then
# [[ "$1" =~ $2 ]] && shini_retval=${BASH_REMATCH[1]} || shini_retval="$1"
# return 0
# fi
shini_retval="$(printf '%s' "$1" | sed -E "s/$2/\1/")" # If you have isses on older systems,
# it may be the non-newer POSIX compliant sed.
# -E should be enabling extended regex mode portably.
}
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Sorry for the delay. tc@piCorePlayer:~$ ash --help |
Hi. Thanks for the changes now shini parse the file fine using busybox ash. It is still very slow (on a Raspberry pi Zerro Wireless) here is the result:
Do you think that you can improve the speed on ash as well? I noticed this discussion here: I don't know if the last answer on that page will improve speed? |
No problem, I realised there was a bug breaking the "fallback" functionality (which as you rightly notice, is extremely slow even on the best of hardware), which I've patched. I too had read that article, but haven't had time to confirm it works yet. I'll give it a whirl this weekend and let you know. (I'm able to test locally against I'll let you know ASAP. Thanks for your patience... :-) |
Hi there. Is there anything I can do to help you in the process of making shini faster using busybox or ash? |
I've had an extensive think about the problem and tried to debug where the duration is being spent. I suspected - and I believe have now proved beyond doubt - that the slowness comes from calling Thus the performance is significantly faster in I'm not that familiar with I've spent some time trying to use named pipes, so there's only one Otherwise I'm afraid I'm out of ideas, except to suggest switching to another library which you could call via anything else you have available (Python/PHP) or knock something up in C. (I'm happy to give that a go if you're willing to compile+ship it with your project. Bit of an ache though!) There might be some further micro-optimisations around the order of execution etc, but I don't think it'll make enough of a difference for as long as FYI - these are the performance gains by using builtins from other shells. Note it is still sped up by searching a specific section rather than the entire file - but still awfully slow in
|
Thanks for trying.
So can the expr command be useful? |
OK, with the greatest emphasis - please don't get overly excited because I've not extensively tested this (and haven't yet found a way to get myself easy access to a busybox install!) But, if I've correctly implemented what you found, these are the new speeds on
I'll commit and push the (experimental) change to a separate branch and post details here momentarily. |
https://github.com/wallyhall/shini/compare/expr-experimental Simple change, I had tried |
If I comment that section again like this:
I get these results - so still a speed improvement compared to before but there is still room for improvement:
So this section needs further changes. I think it is this If I test this section I get this error:
I managed to get the time down to "real 1m 27.95s" if I changed the script to this (t I think I then force it to use your new method?
|
Regarding this issue:
You are correct. It appears I think when you "force" it to use the I'm guessing the rasberrypi hardware (is that what you're running the test on?) is just woefully less powerful than the busybox VM I have (which completes in 3.8s). The Assuming the
|
Thanks for working on this - it is good you found a busybox environtment.
The the terminal shows that this function get called two or three times for each variable?
|
Hi
|
Hi. First thank you for providing shini it is working fine.
I would like to request a new feature, because if we have a long ini file it takes a long time to read, and we often only need to read a specific section of the ini file.
So could you add the possibility to only read the variables in a specified section?
Thanks
The text was updated successfully, but these errors were encountered: