diff --git a/GTM.xcodeproj/project.pbxproj b/GTM.xcodeproj/project.pbxproj index da0cd74..7769383 100644 --- a/GTM.xcodeproj/project.pbxproj +++ b/GTM.xcodeproj/project.pbxproj @@ -24,8 +24,6 @@ 8B29078711F8D1BF0064F50F /* GTMNSFileHandle+UniqueName.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B29078511F8D1BF0064F50F /* GTMNSFileHandle+UniqueName.m */; }; 8B29080911F8E1630064F50F /* GTMNSFileHandle+UniqueName.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B29078511F8D1BF0064F50F /* GTMNSFileHandle+UniqueName.m */; }; 8B29080A11F8E1670064F50F /* GTMNSFileHandle+UniqueName.h in Headers */ = {isa = PBXBuildFile; fileRef = 8B29078411F8D1BF0064F50F /* GTMNSFileHandle+UniqueName.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 8B3590160E8190FA0041E21C /* GTMTestTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 8B3590150E8190FA0041E21C /* GTMTestTimer.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 8B35901B0E8191750041E21C /* GTMTestTimerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B35901A0E8191750041E21C /* GTMTestTimerTest.m */; }; 8B3E2A3F0EEB564D000681D8 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F42E09AD0D19A62F00D5DDE0 /* Carbon.framework */; }; 8B40994B0F93C5CC00DF540E /* GTMUILocalizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 8B4099490F93C5CC00DF540E /* GTMUILocalizer.h */; settings = {ATTRIBUTES = (Public, ); }; }; 8B40994C0F93C5CC00DF540E /* GTMUILocalizer.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B40994A0F93C5CC00DF540E /* GTMUILocalizer.m */; }; @@ -194,8 +192,6 @@ 8B29078411F8D1BF0064F50F /* GTMNSFileHandle+UniqueName.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GTMNSFileHandle+UniqueName.h"; sourceTree = ""; }; 8B29078511F8D1BF0064F50F /* GTMNSFileHandle+UniqueName.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GTMNSFileHandle+UniqueName.m"; sourceTree = ""; }; 8B29078611F8D1BF0064F50F /* GTMNSFileHandle+UniqueNameTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GTMNSFileHandle+UniqueNameTest.m"; sourceTree = ""; }; - 8B3590150E8190FA0041E21C /* GTMTestTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTMTestTimer.h; sourceTree = ""; }; - 8B35901A0E8191750041E21C /* GTMTestTimerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTMTestTimerTest.m; sourceTree = ""; }; 8B4099490F93C5CC00DF540E /* GTMUILocalizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTMUILocalizer.h; sourceTree = ""; }; 8B40994A0F93C5CC00DF540E /* GTMUILocalizer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTMUILocalizer.m; sourceTree = ""; }; 8B409BC50F94405A00DF540E /* GTMUILocalizerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTMUILocalizerTest.m; sourceTree = ""; }; @@ -601,8 +597,6 @@ F48FE29F0D198D36009257D2 /* GTMSenTestCase.h */, 8B7DCE180DFF39850017E983 /* GTMSenTestCase.m */, F47466651296F19E0022C1FB /* GTMSenTestCaseTest.m */, - 8B3590150E8190FA0041E21C /* GTMTestTimer.h */, - 8B35901A0E8191750041E21C /* GTMTestTimerTest.m */, 8BA983C21D9AE7E6009724B5 /* TestData */, 8B45A2A20DA49C47001148C5 /* GTMUIUnitTestingHarness */, ); @@ -667,7 +661,6 @@ F92B9FA80E2E64B900A2FE61 /* GTMLogger.h in Headers */, F92B9FA90E2E64BC00A2FE61 /* GTMLogger+ASL.h in Headers */, F95803FA0E2FB08F0049A088 /* GTMLoggerRingBufferWriter.h in Headers */, - 8B3590160E8190FA0041E21C /* GTMTestTimer.h in Headers */, 8B6F4B630E8856CA00425D9F /* GTMDebugThreadValidation.h in Headers */, F41711350ECDFBD500B9B276 /* GTMLightweightProxy.h in Headers */, 8B6C15930F356E6400E51E5D /* GTMNSObject+KeyValueObserving.h in Headers */, @@ -906,7 +899,6 @@ files = ( 8B45A21A0DA46E1D001148C5 /* GTMGeometryUtils.m in Sources */, 8B7DCE1B0DFF39850017E983 /* GTMSenTestCase.m in Sources */, - 8B35901B0E8191750041E21C /* GTMTestTimerTest.m in Sources */, F47466661296F19E0022C1FB /* GTMSenTestCaseTest.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/GTMiPhone.xcodeproj/project.pbxproj b/GTMiPhone.xcodeproj/project.pbxproj index 0afcd7e..6026f0f 100644 --- a/GTMiPhone.xcodeproj/project.pbxproj +++ b/GTMiPhone.xcodeproj/project.pbxproj @@ -3,11 +3,10 @@ archiveVersion = 1; classes = { }; - objectVersion = 53; + objectVersion = 46; objects = { /* Begin PBXBuildFile section */ - 8B2C72EB1D9EBBA10027BD14 /* GTMTestTimerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B2C72EA1D9EBBA10027BD14 /* GTMTestTimerTest.m */; }; 8B5769B121CD7C8300D924D3 /* GTMTimeUtilsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B5769AD21CD7C7600D924D3 /* GTMTimeUtilsTest.m */; }; 8B5769B221CD7C8600D924D3 /* GTMTimeUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B5769AC21CD7C7600D924D3 /* GTMTimeUtils.m */; }; 8B7651D81D9C872F00DB2C59 /* GTMLogger+ASL.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B7651D61D9C872C00DB2C59 /* GTMLogger+ASL.m */; }; @@ -99,8 +98,6 @@ 8B2908AF11F8E7070064F50F /* GTMNSFileHandle+UniqueName.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GTMNSFileHandle+UniqueName.h"; sourceTree = ""; }; 8B2908B011F8E7070064F50F /* GTMNSFileHandle+UniqueName.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GTMNSFileHandle+UniqueName.m"; sourceTree = ""; }; 8B2908B111F8E7070064F50F /* GTMNSFileHandle+UniqueNameTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GTMNSFileHandle+UniqueNameTest.m"; sourceTree = ""; }; - 8B2C72E91D9EBBA10027BD14 /* GTMTestTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTMTestTimer.h; sourceTree = ""; }; - 8B2C72EA1D9EBBA10027BD14 /* GTMTestTimerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTMTestTimerTest.m; sourceTree = ""; }; 8B308BCD0DAD0B8400183556 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 8B3AA9330E0336AC007E31B5 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; }; 8B5769AC21CD7C7600D924D3 /* GTMTimeUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTMTimeUtils.m; sourceTree = ""; }; @@ -358,8 +355,6 @@ 8BC047F60DAE928A00C2D1CA /* GTMSenTestCase.h */, 8BC047F70DAE928A00C2D1CA /* GTMSenTestCase.m */, F4746720129703600022C1FB /* GTMSenTestCaseTest.m */, - 8B2C72E91D9EBBA10027BD14 /* GTMTestTimer.h */, - 8B2C72EA1D9EBBA10027BD14 /* GTMTestTimerTest.m */, F435E49F0DC8F5290069CDE8 /* TestData */, ); path = UnitTesting; @@ -551,7 +546,6 @@ 8B82CF3E1D9C2373007182AA /* GTMNSFileHandle+UniqueNameTest.m in Sources */, 8B82CF501D9C2385007182AA /* GTMSenTestCaseTest.m in Sources */, 8B82CF471D9C2373007182AA /* GTMStackTraceTest.m in Sources */, - 8B2C72EB1D9EBBA10027BD14 /* GTMTestTimerTest.m in Sources */, 8B82CF401D9C2373007182AA /* GTMNSObject+KeyValueObservingTest.m in Sources */, 8B82CF451D9C2373007182AA /* GTMNSThread+BlocksTest.m in Sources */, ); @@ -593,11 +587,7 @@ DEAD_CODE_STRIPPING = YES; GTM_HOST_OTHER_LDFLAGS = "-ObjC -lz"; INFOPLIST_FILE = "UnitTest-Info.plist"; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -611,11 +601,7 @@ DEAD_CODE_STRIPPING = YES; GTM_HOST_OTHER_LDFLAGS = "-ObjC -lz"; INFOPLIST_FILE = "UnitTest-Info.plist"; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; diff --git a/GoogleToolboxForMac.podspec b/GoogleToolboxForMac.podspec index 9bf2386..ae6b180 100644 --- a/GoogleToolboxForMac.podspec +++ b/GoogleToolboxForMac.podspec @@ -160,8 +160,4 @@ Pod::Spec.new do |s| } end - s.subspec 'TestTimer' do |sp| - sp.source_files = 'UnitTesting/GTMTestTimer.h' - end - end diff --git a/UnitTesting/BUILD b/UnitTesting/BUILD index b51ee42..29f7cfe 100644 --- a/UnitTesting/BUILD +++ b/UnitTesting/BUILD @@ -1,18 +1,6 @@ load("@build_bazel_rules_apple//apple:ios.bzl", "ios_build_test") load("@build_bazel_rules_apple//apple:macos.bzl", "macos_build_test") -objc_library( - name = "TestTimer", - testonly = 1, - hdrs = [ - "GTMTestTimer.h", - ], - visibility = ["//visibility:public"], - deps = [ - "//:Defines", - ], -) - objc_library( name = "SenTestCase", testonly = 1, @@ -32,7 +20,6 @@ ios_build_test( name = "iOSBuildTest", minimum_os_version = "12.0", targets = [ - ":TestTimer", ":SenTestCase", ], ) @@ -41,7 +28,6 @@ macos_build_test( name = "macOSBuildTest", minimum_os_version = "10.10", targets = [ - ":TestTimer", ":SenTestCase", ], ) diff --git a/UnitTesting/GTMTestTimer.h b/UnitTesting/GTMTestTimer.h deleted file mode 100644 index dadd047..0000000 --- a/UnitTesting/GTMTestTimer.h +++ /dev/null @@ -1,128 +0,0 @@ -// -// GTMTestTimer.h -// -// Copyright 2006-2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); you may not -// use this file except in compliance with the License. You may obtain a copy -// of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -// License for the specific language governing permissions and limitations under -// the License. -// - -#import -#import "GTMDefines.h" -#import -#include - -NS_ASSUME_NONNULL_BEGIN - -// GTMTestTimer is done in straight inline C to avoid obj-c calling overhead. -// It is for doing test timings at very high precision. -// Test Timers have standard CoreFoundation Retain/Release rules. -// Test Timers are not thread safe. Test Timers do NOT check their arguments -// for NULL. You will crash if you pass a NULL argument in. - -typedef struct GTMTestTimer { - mach_timebase_info_data_t time_base_info_; - bool running_; - uint64_t start_; - uint64_t split_; - uint64_t elapsed_; - NSUInteger iterations_; - NSUInteger retainCount_; -} GTMTestTimer; - -// Create a test timer -GTM_INLINE GTMTestTimer *GTMTestTimerCreate(void) { - GTMTestTimer *t = (GTMTestTimer *)calloc(sizeof(GTMTestTimer), 1); - if (t && mach_timebase_info(&t->time_base_info_) == KERN_SUCCESS) { - t->retainCount_ = 1; - } else { - // COV_NF_START - if (t) free(t); - abort(); - // COV_NF_END - } - return t; -} - -// Retain a timer -GTM_INLINE void GTMTestTimerRetain(GTMTestTimer *t) { - t->retainCount_ += 1; -} - -// Release a timer. When release count hits zero, we free it. -GTM_INLINE void GTMTestTimerRelease(GTMTestTimer *t) { - t->retainCount_ -= 1; - if (t->retainCount_ == 0) { - free(t); - } -} - -// Starts a timer timing. Specifically starts a new split. If the timer is -// currently running, it resets the start time of the current split. -GTM_INLINE void GTMTestTimerStart(GTMTestTimer *t) { - t->start_ = mach_absolute_time(); - t->running_ = true; -} - -// Stops a timer and returns split time (time from last start) in nanoseconds. -GTM_INLINE uint64_t GTMTestTimerStop(GTMTestTimer *t) { - uint64_t now = mach_absolute_time(); - t->running_ = false; - ++t->iterations_; - t->split_ = now - t->start_; - t->elapsed_ += t->split_; - t->start_ = 0; - return t->split_; -} - -// returns the current timer elapsed time (combined value of all splits, plus -// current split if the timer is running) in nanoseconds. -GTM_INLINE double GTMTestTimerGetNanoseconds(GTMTestTimer *t) { - uint64_t total = t->elapsed_; - if (t->running_) { - total += mach_absolute_time() - t->start_; - } - return (double)(total * t->time_base_info_.numer - / t->time_base_info_.denom); -} - -// Returns the current timer elapsed time (combined value of all splits, plus -// current split if the timer is running) in seconds. -GTM_INLINE double GTMTestTimerGetSeconds(GTMTestTimer *t) { - return GTMTestTimerGetNanoseconds(t) * 0.000000001; -} - -// Returns the current timer elapsed time (combined value of all splits, plus -// current split if the timer is running) in milliseconds. -GTM_INLINE double GTMTestTimerGetMilliseconds(GTMTestTimer *t) { - return GTMTestTimerGetNanoseconds(t) * 0.000001; -} - -// Returns the current timer elapsed time (combined value of all splits, plus -// current split if the timer is running) in microseconds. -GTM_INLINE double GTMTestTimerGetMicroseconds(GTMTestTimer *t) { - return GTMTestTimerGetNanoseconds(t) * 0.001; -} - -// Returns the number of splits (start-stop) cycles recorded. -// GTMTestTimerGetSeconds()/GTMTestTimerGetIterations() gives you an average -// of all your splits. -GTM_INLINE NSUInteger GTMTestTimerGetIterations(GTMTestTimer *t) { - return t->iterations_; -} - -// Returns true if the timer is running. -GTM_INLINE bool GTMTestTimerIsRunning(GTMTestTimer *t) { - return t->running_; -} - -NS_ASSUME_NONNULL_END diff --git a/UnitTesting/GTMTestTimerTest.m b/UnitTesting/GTMTestTimerTest.m deleted file mode 100644 index 27758ff..0000000 --- a/UnitTesting/GTMTestTimerTest.m +++ /dev/null @@ -1,56 +0,0 @@ -// -// GTMTestTimerTest.m -// -// Copyright 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); you may not -// use this file except in compliance with the License. You may obtain a copy -// of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -// License for the specific language governing permissions and limitations under -// the License. -// - -#import "GTMSenTestCase.h" -#import "GTMTestTimer.h" - -@interface GTMTestTimerTest : GTMTestCase -@end - -@implementation GTMTestTimerTest -- (void)testTimer { - GTMTestTimer *timer = GTMTestTimerCreate(); - XCTAssertNotNULL(timer); - GTMTestTimerRetain(timer); - GTMTestTimerRelease(timer); - XCTAssertEqualWithAccuracy(GTMTestTimerGetSeconds(timer), 0.0, 0.0); - GTMTestTimerStart(timer); - XCTAssertTrue(GTMTestTimerIsRunning(timer)); - NSRunLoop *loop = [NSRunLoop currentRunLoop]; - [loop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; - GTMTestTimerStop(timer); - - // We use greater than (and an almost absurd less than) because - // these tests are very dependant on machine load, and we don't want - // automated tests reporting false negatives. - XCTAssertGreaterThan(GTMTestTimerGetSeconds(timer), 0.1); - XCTAssertGreaterThan(GTMTestTimerGetMilliseconds(timer), 100.0); - XCTAssertGreaterThan(GTMTestTimerGetMicroseconds(timer), 100000.0); - - // Check to make sure we're not WAY off the mark (by a factor of 10) - XCTAssertLessThan(GTMTestTimerGetMicroseconds(timer), 1000000.0); - - [loop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; - GTMTestTimerStart(timer); - [loop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; - XCTAssertGreaterThan(GTMTestTimerGetSeconds(timer), 0.2); - GTMTestTimerStop(timer); - XCTAssertEqual(GTMTestTimerGetIterations(timer), (NSUInteger)2); - GTMTestTimerRelease(timer); -} -@end