Turn on thread page Beta
    • Thread Starter

    Hi so i'm at the testing part of my computing coursework and i'm trying to create a trace table for a particular routine which is a nested for loop linear search, it's basically searching live neighbours but in a 2D array, i was wondering if anyone has any ideas of how i could test this works efficiently

    Here's the code:
    for Row := YMin to YMax do
    for Col := XMin to XMax do
    if (Row <> Y) or (Col <> X) then
    if CopyArray[Row, Col].IsAlive then
    LiveNeighbourCount := LiveNeighbourCount + 1
    if LiveNeighbourCount > 3 then begin Result := False

    case CurrentlyAlive of
    if LiveNeighbourCount < 2 then
    Result := False
    else if LiveNeighbourCount > 3 then
    Result := False
    else Result := True
    begin if LiveNeighbourCount = 3 then
    Result := True
    else Result := False

    Thanks for any help in advance

    Before being able to test anything, you must first be able to define the objective of that test. So the question "How do I test that this works efficiently" is meaningless and unanswerable until you can quantify the term "efficiently" - i.e. What are your performance requirements versus what kind of data set? Are there 100 entries, 10,000 or 10,000,000 in the data? Should it run in under 1ms? under 100ms? under 1sec? ... 10 sec? .. 1 hour?

    The code you've written looks like Delphi to me, so if you are trying to profile some code, then TStopwatch works like a high-resolution timer which is ideal for analysing the performance characteristics of some code:

    Before you jump in and start doing this, the most important question to ask is why you're doing this. Performance, Efficiency and Optimisation are only important in situations where your app exhibits some observable behaviour indicating that "something" might be slow - For example, are you having problems with updates in a UI or experiencing some kind of input lag?

    Also remember that just because an app is running slowly doesn't mean that there's an issue with efficiency, - sometimes apps run slowly because there are blocking calls to a "wait", or "sleep" causing the app to appear to do nothing when in fact a thread has just been temporarily suspended, and the solution is to restructure the app to remove those blocking calls, or to dispatch them out to a separate thread.

University open days

  • Staffordshire University
    Everything except: Midwifery, Operating Department Practice, Paramedic Undergraduate
    Sun, 21 Oct '18
  • University of Exeter
    Undergraduate Open Days - Exeter Campus Undergraduate
    Wed, 24 Oct '18
  • University of Bradford
    Faculty of Health Studies Postgraduate
    Wed, 24 Oct '18
Who is most responsible for your success at university
Help with your A-levels

All the essentials

The adventure begins mug

Student life: what to expect

What it's really like going to uni


Essay expert

Learn to write like a pro with our ultimate essay guide.

Uni match

Uni match

Our tool will help you find the perfect course for you

Study planner

Create a study plan

Get your head around what you need to do and when with the study planner tool.

Study planner

Resources by subject

Everything from mind maps to class notes.

Hands typing

Degrees without fees

Discover more about degree-level apprenticeships.

A student doing homework

Study tips from A* students

Students who got top grades in their A-levels share their secrets

Study help links and info

Can you help? Study help unanswered threadsRules and posting guidelines

Groups associated with this forum:

View associated groups

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.