Timing tweaks and minor optimisation

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@10266 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2001-06-27 10:25:54 +00:00
parent 96aee78f1a
commit 55459b00d7
4 changed files with 57 additions and 19 deletions

View file

@ -2,6 +2,12 @@
* Source/callframe.m: callframe_do_call_opts(),
callframe_build_return_opts() fixed memory leaks.
Performance improvements -
callframe_from_info() use a single malloc to allocate memory for
the entire callframe. callframe_free() use a single free()
* Source/NSConnection.m: Wait only 0.1 millisecond for first try
checking for events ... CPUs are getting faster.
* Source/NSTimer.m: Set minimum timer to 0.1 milliseconds ...
2001-06-26 Adam Fedor <fedor@gnu.org>

View file

@ -2324,7 +2324,7 @@ static BOOL multi_threaded = NO;
NSPortCoder *rmc;
GSIMapNode node;
NSDate *timeout_date = nil;
NSTimeInterval delay_interval = 0.001;
NSTimeInterval delay_interval = 0.0001;
NSDate *delay_date = nil;
NSRunLoop *runLoop = [runLoopClass currentRunLoop];

View file

@ -50,7 +50,7 @@ static Class NSDate_class;
{
if (seconds <= 0)
{
seconds = 0.001;
seconds = 0.0001;
}
_interval = seconds;
_date = [[NSDate_class allocWithZone: [self zone]]

View file

@ -45,22 +45,63 @@ extern BOOL sel_types_match(const char* t1, const char* t2);
callframe_t *
callframe_from_info (NSArgumentInfo *info, int numargs, void **retval)
{
int i;
callframe_t *cframe;
unsigned size = sizeof(callframe_t);
unsigned align = __alignof(double);
unsigned offset;
void *buf;
int i;
callframe_t *cframe;
cframe = malloc(sizeof(callframe_t));
cframe->nargs = numargs;
if (numargs > 0)
{
if (size % align != 0)
{
size += align - (size % align);
}
offset = size;
size += numargs * sizeof(void*);
if (size % align != 0)
{
size += (align - (size % align));
}
for (i = 0; i < numargs; i++)
{
size += info[i+1].size;
if (size % align != 0)
{
size += (align - size % align);
}
}
}
cframe = buf = malloc(size);
if (cframe)
{
cframe->args = malloc(cframe->nargs * sizeof(void *));
cframe->nargs = numargs;
cframe->args = buf + offset;
offset += numargs * sizeof(void*);
if (offset % align != 0)
{
offset += align - (offset % align);
}
for (i = 0; i < cframe->nargs; i++)
cframe->args[i] = malloc(info[i+1].size);
{
cframe->args[i] = buf + offset;
offset += info[i+1].size;
if (offset % align != 0)
{
offset += (align - offset % align);
}
}
}
if (retval)
{
*retval = NSZoneMalloc(NSDefaultMallocZone(),
MAX(info[0].size, sizeof(smallret_t)) );
*retval = NSZoneMalloc(NSDefaultMallocZone(),
MAX(info[0].size, sizeof(smallret_t)) );
}
return cframe;
}
@ -68,15 +109,6 @@ callframe_from_info (NSArgumentInfo *info, int numargs, void **retval)
void
callframe_free(callframe_t *cframe)
{
int i;
for (i = 0; i < cframe->nargs; i++)
{
free(cframe->args[i]);
cframe->args[i] = 0;
}
cframe->nargs = 0;
free(cframe->args);
free(cframe);
}