On Thursday, June 5, 2014 7:11:11 AM UTC+2, John Myles White wrote: > I think your loop might be more performant if you were looping over Uint > values rather than Int values. >
Sure. I tried using an Int array, which helped a little, but I've also tried pushing Uints now. (The motivation for that in my case would be pushing object_id returns.) My benchmark setup is here: https://gist.github.com/mlhetland/47bb6a624af3432118bb My results: | Row # | Function | Average | Relative | Replications | | 1 | "push_int_any" | 0.0219446 | 1.0 | 100 | | 2 | "asgn_int_any" | 0.0293365 | 1.33684 | 100 | | 3 | "asgn_check_int_any" | 0.0342796 | 1.56209 | 100 | | 4 | "asgn_check_id_uint" | 0.0306131 | 1.39501 | 100 | | 5 | "push_id_uint" | 0.0263455 | 1.20055 | 100 | | 6 | "push_int_uint" | 0.0276287 | 1.25902 | 100 | | 7 | "push_entry_any" | 0.0223655 | 1.01918 | 100 | | 8 | "push_enryid_uint" | 0.0243882 | 1.11135 | 100 | | 9 | "push_int_int" | 0.0231472 | 1.0548 | 100 | | 10 | "push_uint_uint" | 0.0227038 | 1.03459 | 100 | I tried adding @inbounds for the assignments, but that didn't seem to help much. Pushing Int to Int and Uint to Uint seem pretty close to pushing Int to Any. I guess the differences could even be timing artefacts (due to ordering or the like). Dunno. But form what I can see, the simple, straightforward approach of simply using a cell array with push! and resize! does not entail any overhead? I guess there would be no difference for simple assignments such as swapping entries either? -- John >
