Any suggestion to load 40,000 words FAST to Array (Solve)

Get help using Construct 2

Post » Wed Dec 23, 2015 10:33 am

Any suggest to load 40,000 words FAST from a Text file or any other file that will load FAST to array currently i am using Ajax this
tokenat(AJAX.LastData,i,";")
but chrome become unresponsive
trying to make a word game only to load word fast i cant figure out
my test
4000 word load in 3 second
15000 word load in 40+ second
29770 word crash chrome or make non responsive
here is the text file
https://drive.google.com/open?id=0B0MCC ... HlCME1Ga3c
Last edited by wizdigitech on Wed Dec 23, 2015 10:29 pm, edited 2 times in total.
Image
B
33
S
10
G
2
Posts: 303
Reputation: 3,539

Post » Wed Dec 23, 2015 3:24 pm

This should be faster. I've used something similar before to load the entire English dictionary.

Global text data=""
Global text word=""
Global text c=""

On ajax complete
-> set data to Ajax.lastData
--- repeat len(data) times
--- -> set c to mid(data, loopindex, 1)
--- --- system: c=";"
--- --- -> array: push back word
--- --- -> set word to ""
--- --- else
--- --- -> add c to word
B
87
S
29
G
89
Posts: 5,103
Reputation: 60,192

Post » Wed Dec 23, 2015 5:23 pm

@R0J0hound

Thanks for this.

Surprisingly, it appears to take longer for Ajax On Completed to fire than it does to populate the array. Still barely a second for both parts, but there is a micro pause waiting for Ajax.

Interesting.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
129
S
29
G
74
Posts: 5,140
Reputation: 52,685

Post » Wed Dec 23, 2015 6:26 pm

@zenox98
The pause with ajax is the time it takes to load the file into memory from the disk. The disk is the slowdown here. When the project is exported then it would likely take longer to load from the net than from the disk.
B
87
S
29
G
89
Posts: 5,103
Reputation: 60,192

Post » Wed Dec 23, 2015 9:39 pm

@R0J0hound or @zenox98 can you check if i am writing the code correct because it is not working for me thanks in advance.

https://drive.google.com/open?id=0B0MCC ... zVTbktQM1k
Image
B
33
S
10
G
2
Posts: 303
Reputation: 3,539

Post » Wed Dec 23, 2015 9:46 pm

@wizdigitech
wizdigitech wrote:@R0J0hound or @zenox98 can you check if i am writing the code correct because it is not working for me thanks in advance.

https://drive.google.com/open?id=0B0MCC ... zVTbktQM1k


Your Event 5 is backwards.

It should be

'Add c to word'

whereas you have

'Add word to c'

After that, looks like it should work.

BTW you shouldn't need to change the array default from [10,1,1].

You can test by setting a TextBox to the array's Array.AsJson.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
129
S
29
G
74
Posts: 5,140
Reputation: 52,685

Post » Wed Dec 23, 2015 10:06 pm

still dont work here is 2 pic and the update .capx file

pic
https://drive.google.com/open?id=0B0MCC ... WJFWWMtYkE
https://drive.google.com/open?id=0B0MCC ... XZBVUZiREk

.capx
https://drive.google.com/open?id=0B0MCC ... XZBVUZiREk

check with text.json show it work but why chrome crash in debug when i click on the array
https://drive.google.com/open?id=0B0MCC ... khXYzhkNVk
Image
B
33
S
10
G
2
Posts: 303
Reputation: 3,539

Post » Wed Dec 23, 2015 10:18 pm

Hold on a sec - I'll upload yours that I amended to Dropbox for you to try.......

https://dl.dropboxusercontent.com/u/34306693/loadarrayfast.capx

When run (I'm using firefox) you should see your data in the textbox as json data(just for testing).

If this crashes on you using chrome, then I'd point the finger at chrome.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
129
S
29
G
74
Posts: 5,140
Reputation: 52,685

Post » Wed Dec 23, 2015 10:29 pm

strange my one crash yours work zenox98 (your file i just download lol) i can view the array in debug thanks
THANK YOU BOTH
@R0J0hound and @zenox98
Image
B
33
S
10
G
2
Posts: 303
Reputation: 3,539

Post » Wed Dec 23, 2015 10:45 pm

@wizdigitech
Just don't use the debugger to view the contents of the array and it won't crash. Actually you should start the array with size (0,1,1). The push will increase the size.

Alternatively here's another way I did a while ago. It sets the size of the array from the get-go and then uses find() to save on having to loop over every character.
viewtopic.php?f=146&t=72255&p=606405&hilit=dictionary#p606405
B
87
S
29
G
89
Posts: 5,103
Reputation: 60,192

Next

Return to How do I....?

Who is online

Users browsing this forum: PreacH and 9 guests