test_arr_h(20);
function test_arr_h(l_buf4) {
var buffer = new ArrayBuffer(l_buf4*4);
var Uint32 = new Uint32Array(buffer);
var arr_h = [];
let ws=Api.GetActiveSheet();
ws.GetRange("1:20").Clear();
for(var i = 0; i < l_buf4; ++i) {
Uint32[i] = ((Math.random() * 0x100) | 0)+1000*i;
arr_h[i] = Uint32[i];
}
let l_uint=Uint32.length;
let l_arr_h=arr_h.length;
console.log("buffer:"+buffer.byteLength);
console.log("Uint32:"+l_uint);
console.log("Length arr_horiz:"+l_arr_h);
let rng_h=ws.GetRange(ws.GetRangeByNumber(2,5),ws.GetRangeByNumber(2,5+l_arr_h-1));
console.time('horiz_arr');
rng_h.SetValue(arr_h);
console.timeEnd('horiz_arr'); //10000 353ms
console.time('horiz_arr_n');
for (let i=0;i<l_uint;i++){ ws.GetRangeByNumber(0,i+5).SetValue(arr_h[i]);}
console.timeEnd('horiz_arr_n'); //10000 470ms
}
test_arr_v(100);
function test_arr_v(l_buf4) {
var buffer = new ArrayBuffer(l_buf4*4);
var Uint32 = new Uint32Array(buffer);
var arr_v = [];
let ws=Api.GetActiveSheet();
ws.GetRange("A:M").Clear();
for(var i = 0; i < l_buf4; ++i) {
Uint32[i] = ((Math.random() * 0x100) | 0)+1000*i;
arr_v[i] = [Uint32[i]];
}
let l_uint=Uint32.length;
let l_arr_v=arr_v.length;
console.log("buffer:"+buffer.byteLength);
console.log("Uint32:"+l_uint);
console.log("arr_vert:"+l_arr_v);
let rng_v=ws.GetRange(ws.GetRangeByNumber(1,1),ws.GetRangeByNumber(1+l_arr_v-1,1));
console.time('vert_arr');
rng_v.SetValue(arr_v);
console.timeEnd('vert_arr');
console.time('vert_arr_n');
for (let i=0;i<l_uint;i++){ ws.GetRangeByNumber(i+1,3).SetValue(arr_v[i]);}
console.timeEnd('vert_arr_n');
}
test_arr_v(10000);
function test_arr_v(l_buf4) {
var buffer = new ArrayBuffer(l_buf4*4);
var Uint32 = new Uint32Array(buffer);
var arr_v = [];
var arr_vs = [];
let ws=Api.GetActiveSheet();
ws.GetRange("A:M").Clear();
for(var i = 0; i < l_buf4; ++i) {
Uint32[i] = ((Math.random() * 0x100) | 0)+1000*i;
arr_v[i] = [Uint32[i]];
arr_vs[i] = [String(Uint32[i])];
// arr_vs[i] = ["!1234567890!"+String(Uint32[i])];
}
let l_uint=Uint32.length;
let l_arr_v=arr_v.length;
console.log("buffer:"+buffer.byteLength);
console.log("Uint32:"+l_uint);
console.log("arr_vert:"+l_arr_v);
// console.log(arr_vs);
let rng_v=ws.GetRange(ws.GetRangeByNumber(1,1),ws.GetRangeByNumber(1+l_buf4-1,1));
let rng_vs=ws.GetRange(ws.GetRangeByNumber(1,2),ws.GetRangeByNumber(1+l_buf4-1,2));
console.time('vert_arr');
rng_v.SetValue(arr_v);
console.timeEnd('vert_arr');
console.time('vert_arrs');
rng_vs.SetValue(arr_vs);
console.timeEnd('vert_arrs');
console.time('vert_arr_n');
for (let i=0;i<l_buf4; i++){ ws.GetRangeByNumber(i+1,3).SetValue(arr_v[i]);}
console.timeEnd('vert_arr_n');
console.time('vert_arr_ns');
for (let i=0;i<l_buf4;i++){ ws.GetRangeByNumber(i+1,4).SetValue(arr_vs[i]);}
console.timeEnd('vert_arr_ns');
}