peterchan75
Supremacy Member
- Joined
- Apr 26, 2003
- Messages
- 6,719
- Reaction score
- 529
Hi davidktw,
I have two sets of code. The first is 5X faster than the latter. The latter code is able to catch the completion of all https events. Why is there a speed difference ?
I have two sets of code. The first is 5X faster than the latter. The latter code is able to catch the completion of all https events. Why is there a speed difference ?
Code:
while (tickers.length > 0) {
var ticker_list = [];
while (ticker_list.length <= ticker_list_num && tickers.length > 0) {
ticker_list.push(tickers[0]);
tickers.splice(0,1)
}
var my_url = url + ticker_list.join(',');
const download_eod = async () => {
try {
const response = await axios.get(my_url);
const body = response.data;
array = body.quoteResponse.result;
return array;
}
catch (error) {
throw error;
}
};
download_eod().then(array => process_json(array));
}
Code:
const download_eod = async () => {
while (tickers.length > 0) {
var ticker_list = [];
while (ticker_list.length <= ticker_list_num && tickers.length > 0) {
ticker_list.push(tickers[0]);
tickers.splice(0,1)
}
var my_url = url + ticker_list.join(',');
try {
const response = await axios.get(my_url);
const body = response.data;
array = body.quoteResponse.result;
eod_array = process_json(array,eod_array);
}
catch (error) {
throw error;
}
}
return (eod_array);
}
download_eod().then(eod_array => output_eod_to_file(eod_array));