[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Performance slowdown using alloc?
From: |
famasce |
Subject: |
Performance slowdown using alloc? |
Date: |
Fri, 14 Apr 2000 10:47:14 +0200 |
To make my code more Swarm-styled (? :-)),I've replaced the following
declaration
unsigned short *matrix;
with
unsigned short **matrix;
then changed matrix allocation from
// C style allocation
matrix= calloc (matrixDim*matrixDim, sizeof(unsigned short));
to
//Swarm style allocation
int index;
matrix=[[self getZone] alloc: matrixDim*sizeof(unsigned short*)];
for (index=0;index<matrixDim;index++)
matrix[index]=[[self getZone] alloc: matrixDim*sixeof(unsigned
short)];
and changed the access method from
*(matrix+ matrixDim*row+col)
to
matrix[row][col]
But doing this I've noticed a slowdown in execution. Considering that I made
this modification only in a small part of the code to test it before
extending it to the whole program, I wonder if it's really worth to go on
only to make the code more readable.
Fabio.
==================================
Swarm-Support is for discussion of the technical details of the day
to day usage of Swarm. For list administration needs (esp.
[un]subscribing), please send a message to <address@hidden>
with "help" in the body of the message.
- Performance slowdown using alloc?,
famasce <=