Update of /cvsroot/hoc/hoc/HOC_cbits
In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv6881/HOC_cbits
Modified Files:
NewClass.m
Added Files:
Statistics.h Statistics.m
Log Message:
a) Utilities cleanup:
remove #* (send message and release result)
add #. (get instance variable)
add declareMarshalledObjectType
b) sending init messages to super is now supported
c) can now implement methods that return a retained object (like init)
--- NEW FILE: Statistics.h ---
#include <objc/objc.h>
enum
{
kHOCAboutToEnterHaskell = 0,
kHOCEnteredHaskell,
kHOCImportedArguments,
kHOCAboutToExportResult,
kHOCAboutToLeaveHaskell,
kHOCLeftHaskell
};
void recordHOCEvent(int what, void ** args);
--- NEW FILE: Statistics.m ---
#import "Statistics.h"
#include <stdint.h>
#include <stdio.h>
//#define DO_TIMINGS
#ifdef DO_TIMINGS
#if !GNUSTEP
#include <mach/mach.h>
#include <mach/mach_time.h>
inline uint64_t abstime()
{ return mach_absolute_time(); }
static double tonano(uint64_t x)
{
uint64_t time = mach_absolute_time();
static mach_timebase_info_data_t sTimebaseInfo;
if ( sTimebaseInfo.denom == 0 ) {
mach_timebase_info(&sTimebaseInfo);
}
return (double)x * sTimebaseInfo.numer / sTimebaseInfo.denom;
}
#endif
#endif
static double enteringTime = 0;
static double importTime = 0;
const double weight = 0.01;
void recordHOCEvent(int what, void ** args)
{
id obj;
SEL sel;
obj = *(id*) args[0];
sel = *(SEL*) args[1];
// printf("recordHOCEvent %d\n", what);
#ifdef DO_TIMINGS
static uint64_t saved;
double time;
switch(what)
{
case kHOCAboutToEnterHaskell:
saved = abstime();
break;
case kHOCEnteredHaskell:
time = tonano(abstime() - saved);
// if(time > 100000)
// printf("Took a long time to enter: %g\n", time);
if(enteringTime != 0)
enteringTime = (1-weight) * enteringTime + weight * time;
else
enteringTime = time;
saved = abstime();
break;
case kHOCImportedArguments:
time = tonano(abstime() - saved);
// if(time > 100000)
// printf("Took a long time to import: %g\n", time);
if(importTime != 0)
importTime = (1-weight) * importTime + weight * time;
else
importTime = time;
break;
}
#endif
}
Index: NewClass.m
===================================================================
RCS file: /cvsroot/hoc/hoc/HOC_cbits/NewClass.m,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- NewClass.m 6 Apr 2004 12:36:13 -0000 1.3
+++ NewClass.m 13 Feb 2007 17:11:04 -0000 1.4
@@ -2,6 +2,7 @@
#include <Foundation/NSException.h>
#include <assert.h>
#include "NewClass.h"
+#include "Statistics.h"
#ifdef GNUSTEP
#define isa class_pointer
@@ -101,7 +102,9 @@
static void objcIMP(ffi_cif *cif, void * ret, void **args, void *userData)
{
+ recordHOCEvent(kHOCAboutToEnterHaskell, args);
NSException *e = (*(haskellIMP)userData)(cif, ret, args);
+ recordHOCEvent(kHOCLeftHaskell, args);
if(e != nil)
[e raise];
}
|