I have a an array of json objects like this -
var resultsArr = [
{
"upvotes": "45",
"postID": "4555",
"numberOfComments": "45",
"shares":"22"
},
{
"upvotes": "21",
"postID": "4665",
"numberOfComments": "20",
"shares":"24"
},
{
"upvotes": "4",
"postID": "77366",
"numberOfComments": "0",
"shares":"4"
},
{
"upvotes": "49",
"postID": "6565",
"numberOfComments": "22",
"shares":"54",
}];
I need to compute a value score based on upvotes,numberOfComments,sharesand then push it back into the JSON dictionary so that every object in array looks like this -
var resultsArr= [{
....
},
{
"upvotes": "49",
"postID": "6565",
"numberOfComments": "22",
"shares":"54",
"score":"20"
}]
I can access the json objects in this array using a for loop but from my understanding goes, it accesses each element in sequence.
Given that I will have roughly 100-200 items in the array, how can I speed up the score computation process to access each element parallelly and thus reduce the time it takes to compute the score for every element in the array?
P.S I'm coding this, with the assumption, that the elements in the array might grow to have 300-400 elements in the future.
Aucun commentaire:
Enregistrer un commentaire