clear all cls set more off mata: real scalar f1(real vector x) { real scalar y, i y = 0 for (i=1; i<=rows(x); i++) { } return(y) } real scalar f2(real vector x) { real scalar y, i, n n = rows(x) y = 0 for (i=1; i<=n; i++) { } return(y) } end loc n 10000000 mata: x = J(`n', 1, 0) forv i=1/10 { timer on 2 mata: (void) f2(x) timer off 2 timer on 1 mata: (void) f1(x) timer off 1 } timer list /* . timer list 1: 6.10 / 10 = 0.6104 2: 4.88 / 10 = 0.4882 */