请问高手,为什么运行得非常慢?如何改进??
想把数据块中的一列(field)做平均,为什么运行得非常慢?如何改进?
...
for(int i=0; i<PointsToRead; i++) /// **1
{
DBTable->First();
while(!DBTable->Eof){ //***2
TField* Field=DBTable->FieldByName(FieldName);
TBlobField* ThisBlob;
ThisBlob=(TBlobField*)Field;
TBlobStream* ThisBlobStream;
ThisBlobStream=new TBlobStream(ThisBlob,bmRead);
int PointsToRead=ThisBlobStream->Size/sizeof(short);
if(PointsToRead<=0)
{
delete ThisBlobStream;
return;
}
short* Data=new short[PointsToRead];
ThisBlobStream->Seek(0, soFromBeginning);
ThisBlobStream->Read(Data, ThisBlobStream->Size);
Value+=Data[i];
delete ThisBlobStream;
delete [] Data;
DBTable->Next();
} //***2
Value=Value/SaveNo;
AnsiString Text;
Text=Value;
Text+="\n";
File->Write(Text.c_str(), Text.Length());
} ///***1