slow runtime
Dr. Smith
iam at far.out
Thu Sep 9 19:40:47 PDT 2010
The class code below runs terribly slow. Conversely, when converted into a
function (albeit returning only one value), it runs fast. Any insights into
this or suggestions to get a function to return multiple types at once?
...library code...
module testlib;
import std.stdio, std.string;
class classtest {
int i, j;
double[][] hit() {
double[][] hi = new double[][](1000, 40);
for(i = 1; i < 1000; i++) {
for(j = 1; j < 40; j++) {
hi[i][j] = (i);
}
}
return hi;
}
double[][] hot() {
double[][] ho = new double[][](1000, 40);
for(i = 1; i < 1000; i++) {
for(j = 1; j < 40; j++) {
ho[i][j] = (j);
}
}
return ho;
}
string stest () {
string hello = "yo!";
return hello;
}
}
... calling code ...
import std.stdio, std.string;
import testlib;
void main() {
classtest obj = new classtest;
int i, j;
for(i = 1; i < obj.hit.length; i++) {
for(j = 1; j < obj.hit[i].length; j++) {
writefln("%s\t%f\t%f", obj.stest, obj.hit[i][j], obj.hot[i][j]);
}
}
}
More information about the Digitalmars-d-learn
mailing list