Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b99e82b
Showing
872 changed files
with
487,537 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Visual Studio Code | ||
.vscode | ||
|
||
# Android Studio, Gradle | ||
*.iml | ||
.gradle | ||
.idea | ||
.settings | ||
.project | ||
.classpath | ||
.DS_Store | ||
.externalNativeBuild | ||
|
||
# Xcode | ||
*.pbxuser | ||
xcuserdata | ||
xcuserdata/* | ||
*.xcworkspace/* | ||
*.xcworkspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[submodule "sqlcipher"] | ||
path = sqlcipher | ||
url = https://github.com/Tencent/sqlcipher.git | ||
[submodule "openssl"] | ||
path = openssl | ||
url = https://github.com/openssl/openssl.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Tencent is pleased to support the open source community by making | ||
* WCDB available. | ||
* | ||
* Copyright (C) 2017 THL A29 Limited, a Tencent company. | ||
* All rights reserved. | ||
* | ||
* Licensed under the BSD 3-Clause License (the "License"); you may not use | ||
* this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* https://opensource.org/licenses/BSD-3-Clause | ||
* | ||
* 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 <Foundation/Foundation.h> | ||
#import <WCDB/WCDB.h> | ||
|
||
@interface WCTBenchmarkObject : NSObject<WCTTableCoding> | ||
|
||
@property int intValue; | ||
@property(retain) NSString* stringValue; | ||
|
||
WCDB_PROPERTY(intValue) | ||
WCDB_PROPERTY(stringValue) | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Tencent is pleased to support the open source community by making | ||
* WCDB available. | ||
* | ||
* Copyright (C) 2017 THL A29 Limited, a Tencent company. | ||
* All rights reserved. | ||
* | ||
* Licensed under the BSD 3-Clause License (the "License"); you may not use | ||
* this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* https://opensource.org/licenses/BSD-3-Clause | ||
* | ||
* 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 "WCTBenchmarkObject.h" | ||
|
||
@implementation WCTBenchmarkObject | ||
|
||
WCDB_IMPLEMENTATION(WCTBenchmarkObject) | ||
WCDB_SYNTHESIZE(WCTBenchmarkObject, intValue) | ||
WCDB_SYNTHESIZE(WCTBenchmarkObject, stringValue) | ||
|
||
WCDB_PRIMARY(WCTBenchmarkObject, intValue) | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Tencent is pleased to support the open source community by making | ||
* WCDB available. | ||
* | ||
* Copyright (C) 2017 THL A29 Limited, a Tencent company. | ||
* All rights reserved. | ||
* | ||
* Licensed under the BSD 3-Clause License (the "License"); you may not use | ||
* this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* https://opensource.org/licenses/BSD-3-Clause | ||
* | ||
* 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 <Foundation/Foundation.h> | ||
|
||
@interface WCTBenchmarkStaticstic : NSObject | ||
|
||
- (void)start; | ||
- (void)tick; | ||
- (void)stop; | ||
|
||
- (NSArray<NSNumber*>*)getElapseTimes; | ||
- (void)report; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Tencent is pleased to support the open source community by making | ||
* WCDB available. | ||
* | ||
* Copyright (C) 2017 THL A29 Limited, a Tencent company. | ||
* All rights reserved. | ||
* | ||
* Licensed under the BSD 3-Clause License (the "License"); you may not use | ||
* this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* https://opensource.org/licenses/BSD-3-Clause | ||
* | ||
* 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 "WCTBenchmarkStaticstic.h" | ||
#import <mach/mach_time.h> | ||
|
||
@implementation WCTBenchmarkStaticstic { | ||
NSMutableArray<NSNumber*>* _ticks; | ||
} | ||
|
||
- (instancetype)init | ||
{ | ||
if (self = [super init]) { | ||
_ticks = [[NSMutableArray alloc] init]; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)start | ||
{ | ||
[self tick]; | ||
} | ||
|
||
- (void)tick | ||
{ | ||
NSNumber* time = [NSNumber numberWithLongLong:mach_absolute_time()]; | ||
[_ticks addObject:time]; | ||
} | ||
|
||
- (void)stop | ||
{ | ||
[self tick]; | ||
} | ||
|
||
- (void)report | ||
{ | ||
for (NSNumber* elapse in [self getElapseTimes]) { | ||
NSLog(@"Tick cost : %f ms", elapse.doubleValue); | ||
} | ||
} | ||
|
||
- (NSArray<NSNumber*>*)getElapseTimes | ||
{ | ||
NSMutableArray<NSNumber*>* elapseTimes = [[NSMutableArray alloc] init]; | ||
mach_timebase_info_data_t info; | ||
mach_timebase_info(&info); | ||
|
||
uint64_t lastTick = 0; | ||
for (NSUInteger i = 0; i < _ticks.count; ++i) { | ||
uint64_t currentTick = _ticks[i].longLongValue; | ||
if (i>0) { | ||
uint64_t elapse = currentTick-lastTick; | ||
double ns = (double)elapse * (double)info.numer / (double)info.denom; | ||
double ms = ns/1000/1000; | ||
[elapseTimes addObject:[NSNumber numberWithDouble:ms]]; | ||
} | ||
lastTick = currentTick; | ||
} | ||
return elapseTimes; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Tencent is pleased to support the open source community by making | ||
* WCDB available. | ||
* | ||
* Copyright (C) 2017 THL A29 Limited, a Tencent company. | ||
* All rights reserved. | ||
* | ||
* Licensed under the BSD 3-Clause License (the "License"); you may not use | ||
* this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* https://opensource.org/licenses/BSD-3-Clause | ||
* | ||
* 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 <Foundation/Foundation.h> | ||
#import "benchmark_normal.h" | ||
int main(int argc, const char * argv[]) { | ||
#warning TODO Perfect benchmark works | ||
NSString* machPath = [NSString stringWithUTF8String:argv[0]]; | ||
NSString* baseDirectory = [[machPath stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"SampleDB"]; | ||
NSLog(@"Base Directory: %@", baseDirectory); | ||
benchmark_normal(baseDirectory); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Tencent is pleased to support the open source community by making | ||
* WCDB available. | ||
* | ||
* Copyright (C) 2017 THL A29 Limited, a Tencent company. | ||
* All rights reserved. | ||
* | ||
* Licensed under the BSD 3-Clause License (the "License"); you may not use | ||
* this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* https://opensource.org/licenses/BSD-3-Clause | ||
* | ||
* 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 <Foundation/Foundation.h> | ||
|
||
void benchmark_normal(NSString* baseDirectory); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Tencent is pleased to support the open source community by making | ||
* WCDB available. | ||
* | ||
* Copyright (C) 2017 THL A29 Limited, a Tencent company. | ||
* All rights reserved. | ||
* | ||
* Licensed under the BSD 3-Clause License (the "License"); you may not use | ||
* this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* https://opensource.org/licenses/BSD-3-Clause | ||
* | ||
* 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 "benchmark_normal.h" | ||
#import "WCTBenchmarkStaticstic.h" | ||
#import "WCTBenchmarkObject.h" | ||
|
||
void benchmark_normal(NSString* baseDirectory) | ||
{ | ||
NSString* className = NSStringFromClass(WCTBenchmarkObject.class); | ||
NSString* path = [baseDirectory stringByAppendingPathComponent:className]; | ||
NSString* tableName = className; | ||
WCTDataBase* database = [[WCTDataBase alloc] initWithPath:path]; | ||
[database close:^{ | ||
[database removeFilesWithError:nil]; | ||
}]; | ||
|
||
{ | ||
BOOL ret = [database createTableAndIndexesOfName:tableName | ||
withClass:WCTBenchmarkObject.class]; | ||
assert(ret); | ||
} | ||
|
||
int count = 100000; | ||
{ | ||
NSMutableArray* objects = [[NSMutableArray alloc] init]; | ||
for (int i = 0; i < count; ++i) { | ||
WCTBenchmarkObject* object = [[WCTBenchmarkObject alloc] init]; | ||
object.intValue = i; | ||
object.stringValue = [NSString stringWithFormat:@"%d", i]; | ||
[objects addObject:object]; | ||
} | ||
WCTTable* table = [database getTableOfName:tableName | ||
withClass:WCTBenchmarkObject.class]; | ||
WCTBenchmarkStaticstic* staticstic = [[WCTBenchmarkStaticstic alloc] init]; | ||
[staticstic start]; | ||
BOOL ret = [table insertObjects:objects]; | ||
[staticstic stop]; | ||
assert(ret); | ||
NSLog(@"Insert %d objects cost %f ms", count, staticstic.getElapseTimes[0].doubleValue); | ||
} | ||
|
||
{ | ||
WCTTable* table = [database getTableOfName:tableName | ||
withClass:WCTBenchmarkObject.class]; | ||
WCTBenchmarkStaticstic* staticstic = [[WCTBenchmarkStaticstic alloc] init]; | ||
[staticstic start]; | ||
NSArray* objects = [table getAllObjects]; | ||
[staticstic stop]; | ||
NSLog(@"Select %lu objects cost %f ms", objects.count, staticstic.getElapseTimes[0].doubleValue); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>en</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>FMWK</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleVersion</key> | ||
<string>$(CURRENT_PROJECT_VERSION)</string> | ||
<key>NSHumanReadableCopyright</key> | ||
<string>Copyright © 2017年 Tencent. All rights reserved.</string> | ||
<key>NSPrincipalClass</key> | ||
<string></string> | ||
</dict> | ||
</plist> |
Oops, something went wrong.