Jump to content

Timing/Efficiency


ober

Recommended Posts

So I have a project where I'm graphing 2 recordsets against each other, and each recordset contains 12000 records. I first pull the data out of a database and dump it into arrays, then I feed those arrays to the graphing function. The users have the option to graph up to 5 channels (columns of data) at a time, so before I was checking to see if the channel was selected and then adding a value to that specific array.

What I've done (and I've run the timing numbers and it is faster) is to calculate the total number of channels that have been selected and us a switch without breaks to figure out how many I have to fill:
[code]    if($result && mssql_num_rows($result) > 0)
    {
        $d0 = array();
        $d1 = array();
        $d2 = array();
        $d3 = array();
        $d4 = array();
        while($row = mssql_fetch_array($result))
        {  
            switch($fldcnt)
            {
                case 5:
                    $d4[] = $row[5];
                case 4:
                    $d3[] = $row[4];
                case 3:
                    $d2[] = $row[3];
                case 2:
                    $d1[] = $row[2];
                case 1:
                    $d0[] = $row[1];
                break;
            }
        }
    }
    else
    {
        $t1ok = false;
        echo '<br/><br/><p class="warn">There is no 10Hz data for test 1.</p>';
    }
[/code]

I guess I'm just curious if someone would have a better way to do this, as I think I've come up with the best solution.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.