Commits

Tuukka Norri committed 522cf2f

Added DTrace instruments for measuring fetch duration
- Also added a corresponding instrument to the template.

  • Participants
  • Parent commits 7abf1a8
  • Branches PGTS-NG

Comments (0)

Files changed (3)

File BaseTenTemplate.tracetemplate

Binary file modified.

File Sources/BXDatabaseContext.m

 #import "BXInvocationRecorder.h"
 #import "BXErrorHandlerDelegate.h"
 #import "BXLogger.h"
+#import "BXProbes.h"
 
 static NSMutableDictionary* gInterfaceClassSchemes = nil;
 static BOOL gHaveAppKitFramework = NO;
 	{
 	    //Always fetch all keys when firing a fault
 		NSArray* keys = [anObject keysIncludedInQuery: aKey];
+		
+		if (BASETEN_BEGIN_FETCH_ENABLED ())
+		{
+			BXEntityDescription* entity = [anObject entity];
+			char* schema_s = strdup ([[entity schemaName] UTF8String]);
+			char* table_s = strdup ([[entity name] UTF8String]);
+			BASETEN_BEGIN_FETCH (self, schema_s, table_s);
+			free (schema_s);
+			free (table_s);
+		}
+		
 	    retval = [mDatabaseInterface fireFault: anObject keys: keys error: &localError];
+		
+		if (BASETEN_END_FETCH_ENABLED ())
+			BASETEN_END_FETCH (1);
+		
 		if (YES == retval)
 			[anObject awakeFromFetchIfNeeded];
 	    BXHandleError (error, localError);
 				excludedFields = [entity attributes: excludedFields];
 				[excludedFields setValue: [NSNumber numberWithBool: YES] forKey: @"excluded"];
 			}
+			
+			if (BASETEN_BEGIN_FETCH_ENABLED ())
+			{
+				char* schema_s = strdup ([[entity schemaName] UTF8String]);
+				char* table_s = strdup ([[entity name] UTF8String]);
+				BASETEN_BEGIN_FETCH (self, schema_s, table_s);
+				free (schema_s);
+				free (table_s);
+			}
+			
 			retval = [mDatabaseInterface executeFetchForEntity: entity withPredicate: predicate 
 											   returningFaults: returnFaults 
 														 class: [entity databaseObjectClass] 
 														 error: &localError];
+			
+			if (BASETEN_END_FETCH_ENABLED ())
+				BASETEN_END_FETCH ([retval count]);
+			
 			if (nil == localError)
 			{
 				[retval makeObjectsPerformSelector: @selector (awakeFromFetchIfNeeded)];

File Sources/BXProbes.d

 
 provider BaseTen
 {
+	probe begin_fetch (void* context, char* schema, char* table);
+	probe end_fetch (long count);
+
 	probe received_pg_notice (void* connection, char* message);
 
 	probe sent_rollback_transaction (void* connection, long status, char* name);