cheat.sh
cheat.sh copied to clipboard
Performance
I've found the performance long way out from the quoted 100ms.
Even when using a local install a simple query takes 1.2 s
Wondering if this is an exception to the rule, and if it is do you have any pointers where to look.

Actually lite mode was faster, but still pretty slow

Thanks!
Could you please also try to access it directly?
$ time curl cht.sh/python/for+loop
# Python for loop decrementing index
#
# I would like to go over the range() function yet again through the
# documentation as provided here: Python 3.4.1 Documentation for
# range(start, stop[, step])
# (https://docs.python.org/3/library/functions.htmlfunc-range)
#
# As shown in the documentation above, you may enter three parameters
# for the range function 'start', 'stop', and 'step', and in the end it
# will give you an immutable sequence.
#
# The 'start' parameter defines when the counter variable for your case
# 'i' should begin at. The 'end' parameter is essentially what the size
# parameter does in your case. And as for what you want, being that you
# wish to decrease the variable 'i' by 1 every loop, you can have the
# parameter 'step' be -1 which signifies that on each iteration of the
# for loop, the variable 'i' will go down by 1.
#
# You can set the 'step' to be -2 or -4 as well, which would make the
# for loop count 'i' down on every increment 2 down or 4 down
# respectively.
#
# Example:
for x in range(9, 3, -3):
print(x)
# Prints out: 9, 6. It starts at 9, ends at 3, and steps down by a
# counter of 3. By the time it reaches 3, it will stop and hence why '3'
# itself is not printed.
#
# EDIT: Just noticed the fact that it appears you may want to decrease
# the 'i' value in the for loop...? What I would do for that then is
# simply have a while loop instead where you would have a variable
# exposed that you can modify at your whim.
test = 0
size = 50
while (test < size)
test += 1
if (some condition):
test -= 1
real 0m0.146s
user 0m0.030s
sys 0m0.012s
In my case it takes 140ms at the moment. Not 100 ms of course, but not far from it
I guess it was a network issue. What is the purpose of a local install if it still needs to connect to an external server?
Even local server needs to query external server for StackOverflow answers. For local script that connects to local server, it probably just a matter of time to port server calls to local library calls.
There are several situations where local installation could be beneficial.
- In case, you don't need SO-based cheat sheets, all cheat sheets collections are available offline,
- Additionally to that, you can use your own local cheat sheets collections.