realbasic-nug
[Top] [All Lists]

Re: Anyway to speed up text file read?

To: "REALbasic NUG" <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Anyway to speed up text file read?
From: "Mathieu Langlois" <realsoftlists at gmail dot com>
Date: Wed, 29 Nov 2006 22:58:33 -0500
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=ad5/ZdfqxpqAJbTaotPt//fT4ew6jkr0TpjS66kiRNHipZhAId3L6W+wWNUIC9ueS9A4J99PyBb4OTSlcce3nDf5WY9SNut4AnciifopVd6M4y0rR8+JyPx2N7PTcvnKIe8Vs2MxXf2f/GtzNMM6QP0pxZwtc7Zj5Nk3ZKSThBU=
References: <494337660611291927k3ece16bfx6e5b6cda0c6f304d at mail dot gmail dot com>
the biggest problem I see is this:

   While NOT mstmInputStream.EOF

     mstrTemp = Trim(mstmInputStream.ReadLine)

     mstrSequence = mstrSequence + mstrTemp

   Wend


This is probably what is costing you big time.  try changing mstrTemp to an
array of string that you keep appending to, and that you will join at the
end.

Math

On 11/29/06, Burke Squires <burkesquires at gmail dot com> wrote:

Hello all,

For a class project I am programming a basic hidden markov model
project. I need to read a text with with string in it with a total
size of about 5 megabytes. The file loading seems VERY slow...is there
anyway to speed it up? Am I doing something wrong?

  If mfldInputFile <> Nil Then

    txtPath(0).Text = mfldInputFile.AbsolutePath

    mstmInputStream = mfldInputFile.OpenAsTextFile

    While NOT mstmInputStream.EOF

      mstrTemp = Trim(mstmInputStream.ReadLine)

      mstrSequence = mstrSequence + mstrTemp

    Wend

    cHMM.SetSequence(mstrSequence)

  End If

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


From  Wed 29 Nov 2006 21:49:56 -0700
Return-Path: <realbasic-nug-bounces at lists dot realsoftware dot com>
X-Original-To: listarchive at realsoftware dot com
Delivered-To: listarchive at realsoftware dot com
Received: by xmail.realsoftware.com (Postfix, from userid 1037)
        id 049811279EE1; Wed, 29 Nov 2006 20:50:26 -0800 (PST)
X-Spam-Checker-Version: SpamAssassin 3.1.1 (2006-03-10) on www.realsoftware.com X-Spam-Level: X-Spam-Status: No, score=-1.6 required=4.5 tests=AWL,BAYES_00,NO_REAL_NAME autolearn=no version=3.1.1
Received: from lists.realsoftware.com (lists.realsoftware.com [209.198.132.125])
        by xmail.realsoftware.com (Postfix) with ESMTP id F33C91279ED2;
        Wed, 29 Nov 2006 20:50:20 -0800 (PST)
Received: from lists.realsoftware.com (localhost [127.0.0.1])
        by lists.realsoftware.com (Postfix) with ESMTP
        id 261D616C0013; Wed, 29 Nov 2006 22:50:06 -0600 (CST)
X-Original-To: realbasic-nug at lists dot realsoftware dot com
Delivered-To: realbasic-nug at lists dot realsoftware dot com
Received: from mail.verex.com (mail.verex.com [66.116.103.197])
        by lists.realsoftware.com (Postfix) with ESMTP id 2B7DE16C0007
        for <realbasic-nug at lists dot realsoftware dot com>;
        Wed, 29 Nov 2006 22:49:59 -0600 (CST)
Received: from [66.116.103.197] (localhost [127.0.0.1])
        by mail.verex.com (Postfix) with SMTP id 416986AACBA
        for <realbasic-nug at lists dot realsoftware dot com>;
        Wed, 29 Nov 2006 21:49:56 -0700 (MST)
Date: Wed, 29 Nov 2006 21:49:56 -0700
From: joe at strout dot net
To: realbasic-nug at lists dot realsoftware dot com
In-Reply-To: <5d7ca37e0611291958n3b1223d2k2f2057a35423f4cc at mail dot gmail dot 
com>
X-Mailer: VerEx Email Gateway
Content-type: text/plain;
Content-transfer-encoding: 7bit
Message-Id: <20061130044956 dot 416986AACBA at mail dot verex dot com>
Subject: Re: Anyway to speed up text file read?
X-BeenThere: realbasic-nug at lists dot realsoftware dot com
X-Mailman-Version: 2.1.2
Precedence: list
Reply-To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Sender: realbasic-nug-bounces at lists dot realsoftware dot com
Errors-To: realbasic-nug-bounces at lists dot realsoftware dot com

On Nov 30, 2006, at 03:58 UTC, Mathieu Langlois wrote:

This is probably what is costing you big time.  try changing mstrTemp
to an
array of string that you keep appending to, and that you will join at
the
end.

I agree, that will be substantially faster.  You might also try reading
the whole file in at once, using Split to break it into an array of
lines, calling Trim on each element, and then Join them back together.

HTH,
- Joe


--
Joe Strout -- joe at strout dot net
Verified Express, LLC     "Making the Internet a Better Place"
http://www.verex.com/

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>