2014-07-09 6 views
9

के साथ असीमित प्रदर्शन टेस्ट मैंने एसिंक्रोनस और प्रदर्शन परीक्षण के लिए नए एक्ससीटीएस्ट एपीआई का पता लगाना शुरू कर दिया है। अलगाव में, डब्ल्यूडब्ल्यूएमसी से एप्पल के उदाहरण अच्छी तरह से काम करते हैं, लेकिन मैं यह समझने में असमर्थ हूं कि उन्हें कैसे गठबंधन करना है। सबसे अच्छा मैं निम्नलिखित के साथ आने में सक्षम हूं, लेकिन मुझे निम्न त्रुटि मिलती है जब यह चलता है:एक्ससीटीएस्ट

एपीआई उल्लंघन - बिना किसी उम्मीद के इंतजार किए प्रतीक्षा करने के लिए कॉल किया गया।

XCTestExpectation *clsQueryReturnedExpectation = [self expectationWithDescription:@"clsQuery returned"]; 

PFCLSClient *theClient = [[PFCLSClient alloc] init]; 

[self measureMetrics:@[XCTPerformanceMetric_WallClockTime] automaticallyStartMeasuring:YES forBlock: ^{ 
    [theClient getStructureOfType:clsImageTypeSVG ForID:idString success: ^(NSDictionary *structureInfo) { 
     [clsQueryReturnedExpectation fulfill]; 
} failure: ^(NSError *error) { 
     XCTFail(); 
     [clsQueryReturnedExpectation fulfill]; 
}]; 

    [self waitForExpectationsWithTimeout:5 handler: ^(NSError *error) { 
     [self stopMeasuring]; 
    }]; 
}]; 

क्या कोई ऐसा कुछ पूरा करने में सक्षम है?

Thx

उत्तर

21

एप्पल से कुछ मदद के साथ, मैं एक समाधान है। मेरे हिस्से पर मूर्खतापूर्ण निरीक्षण क्योंकि यह हल करना बहुत आसान है। काम करने के लिए, आपको बस इतना करना है कि माप के अंदर अपेक्षा ऑब्जेक्ट (clsQueryReturnedExpectation) बनाने के लिए मेट्रिक्स ब्लॉक करें ताकि प्रत्येक बार प्रदर्शन परीक्षण चलने पर इसे फिर से बनाया जा सके।

PFCLSClient *theClient = [[PFCLSClient alloc] init]; 

[self measureMetrics:@[XCTPerformanceMetric_WallClockTime] automaticallyStartMeasuring:YES forBlock: ^{ 
    XCTestExpectation *clsQueryReturnedExpectation = [self expectationWithDescription:@"clsQuery returned"]; 
    [theClient getStructureOfType:clsImageTypeSVG ForID:idString success: ^(NSDictionary *structureInfo) { 
     [clsQueryReturnedExpectation fulfill]; 
    } failure: ^(NSError *error) { 
     XCTFail(); 
     [clsQueryReturnedExpectation fulfill]; 
    }]; 

    [self waitForExpectationsWithTimeout:5 handler: ^(NSError *error) { 
     [self stopMeasuring]; 
    }]; 
}]; 
+0

क्या समय के अलावा अन्य कुछ भी मापा जा सकता है? एपीआई संदर्भ यह कहता है कि यह XCTPerformance मेट्रिक्स की एक सरणी लेता है लेकिन मुझे मापने के लिए कहीं और कुछ नहीं मिल रहा है। –

+0

जहां तक ​​मुझे पता है, नहीं, आप नहीं कर सकते। मैंने एक ही चीज़ पढ़ी है लेकिन लगता है कि ऐप्पल ने इस बिंदु पर कुछ भी लागू नहीं किया है। – spottedrabbit

संबंधित मुद्दे

 संबंधित मुद्दे