Skip to content
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

Much faster "nordvpn list" patch #40

Open
n8w8 opened this issue Dec 4, 2018 · 2 comments
Open

Much faster "nordvpn list" patch #40

n8w8 opened this issue Dec 4, 2018 · 2 comments

Comments

@n8w8
Copy link

n8w8 commented Dec 4, 2018

Hi, thanks for the script. Here is an idea to make the "nordvpn list" function 100x faster.

# original with hot cache
time (
	find /etc/openvpn/client/ -type l -name "nordvpn_*${1}*.conf" \
	    | xargs -L1 basename \
	    | cut -d _ -f 2 \
	    | cut -d . -f 1 \
	    | sort -g
) > /tmp/nordvpn-list-orig

real	0m11,493s
user	0m0,388s
sys	0m2,560s

# equivalent but WAY faster
time (
	find /etc/openvpn/client/ -type l -name "nordvpn_*${1}*.conf" \
	    | rev \
	    | cut -f1 -d/ \
	    | rev \
	    | cut -d _ -f 2 \
	    | cut -d . -f 1 \
	    | sort -g
) > /tmp/nordvpn-list-new

real	0m0,071s
user	0m0,052s
sys	0m0,032s

# or, as the paths are hardcoded anyway, it can be faster still, but not noticeable:
time (
	find /etc/openvpn/client/ -type l -name "nordvpn_*${1}*.conf" \
	    | cut -d _ -f 2 \
	    | cut -d . -f 1 \
	    | sort -g
) > /tmp/nordvpn-list-new2

real	0m0,048s
user	0m0,032s
sys	0m0,008s

md5sum /tmp/nordvpn-list-*
a0b1355aaebbee7cad75152178a5fe19  /tmp/nordvpn-list-new
a0b1355aaebbee7cad75152178a5fe19  /tmp/nordvpn-list-new2
a0b1355aaebbee7cad75152178a5fe19  /tmp/nordvpn-list-orig
@nstinus
Copy link
Owner

nstinus commented May 17, 2019

Sorry for not answering earlier. This is great! Could submit a pull request?
Thanks!

@n8w8
Copy link
Author

n8w8 commented Jul 25, 2020

I almost never use Git(hub), and I lost my account login and notifications, without realizing it.
So I couldn't give a pull request or reply earlier, sorry.
But I see that in the meantime @drybalka has helped with merging it.
Anyway, thanks both of you!
edit: I don't know how to close the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants