I am writing an upload speed test in javascript. I'm using Jquery (and Ajax) so how long it takes to get a response, to send part of the data to the server In theory, the speed of upload should be assessed.
Of course, to meet the individual bandwidth of the user, until I reach the threshold period, I gradually upload large amounts of large and junk data. Currently, I generate the junk data using the following functions, however, it is very slow when the generation of data is megabytes.
function gener_random_data (size) {var chars = "abcdefghijklmnopqrstuvwxyz"; Var random_data = ""; For (var i = 0; i Actually what I am doing is making a part of the bytes to send to the server, however, this is the only way I can search in javascript.
Any help would be appreciated.
Update: I have rewritten my code so that it is a complete repetition of 10 byte string rather than random string.
function gener_random_data (attempt) {var table = {'1': 10, // 10kb '2': 12, // 40kb '3': 14, // 160kb '4' : 16, // 640kb '5': 18, //2.5 MB '6': 20 / 10Mb} var random_data = "abcdefghij"; // for 10 bytes (i = 0; i Now the number of attempts in the function is argued (hence the first time my script attempts to upload, it will file the smallest, then the next smallest, so and so-so forth ). It then becomes a 10 byte string and then keeps adding itself until it reaches the desired length.
Is this the best way? Is there a better way?
Just a comment ?? |
The following is too high in IE:
function gener_random_data1 (size) {var chars = 'abcdefghijklmnopqrstuvwxyz'.split (' '); Var len = chars.length; Var random_data = []; While (size -) {random_data.push (characters [math.rendum () * lane | 0]); } Random random_data.join (''); }
Comments
Post a Comment