Hello lobogaw,
小幫手認為是您使用了太多的迴圈導致運算量大,進而導致運算過久進而逾時。
如果您打開 nthlowestArray 的函數來觀看的話,會發現裡面是使用迴圈來計算。
建議您可以改用 array_sort 來將陣列排序,這樣就不用每次用 nthlowestArray 來抓分位數。
附上小幫手寫的簡單範例:
Array: peA[](0);
var: pe10(0), pe15(0);
array_SetMaxIndex(peA, 1250);
value2 = 0;
for value1 = 1 to 1250 begin
if getfield("本益比", "D")[value1] <> 0 then begin
value2 += 1;
peA[value2] = getfield("本益比", "D")[value1];
end;
end;
array_SetMaxIndex(peA, value2);
Array_Sort(peA, 1, value2, true);
pe10 = peA[ceiling(value2 * 0.1)];
pe15 = pea[ceiling(value2 * 0.15)];
outputField1(pe10, "10分位數");
outputField2(pe15, "15分位數");
ret = 1;
由於沒有使用到前期運算值,所以資料讀取筆數只要設為1筆即可。
2 評論