aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPStringAdditions.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2009-03-19 23:44:06 +0000
committerrowanbeentje <rowan@beent.je>2009-03-19 23:44:06 +0000
commitddf7d62d20614111acdd420075ef762d6deaa8d7 (patch)
treecf5ce70dde9c25d1b21da1cded5cee9f3e562704 /Source/SPStringAdditions.m
parent4a8d0f731bbb03b9ace041d421800e5c6470326a (diff)
downloadsequelpro-ddf7d62d20614111acdd420075ef762d6deaa8d7.tar.gz
sequelpro-ddf7d62d20614111acdd420075ef762d6deaa8d7.tar.bz2
sequelpro-ddf7d62d20614111acdd420075ef762d6deaa8d7.zip
SPSQLParser changes:
- Use method caches for oft-called functions, and support caching of chunks of the underlying string for string walking, resulting in an overall 1.3x-1.4x parsing speedup. - Improve handling of multi-character comment starts (eg / or -) at the very end of strings - When running splitString... methods return even empty strings for consistency. - Update TableDump and TableData to match new usage SPStringAddition changes: - Add a formatter for time intervals. CMMCPConnection changes: - Add support for timing queries CustomQuery and nib changes: - Change the "Run Queries" button to "Run All". - Add a "Run Current" button, which runs the query the text caret is currently positioned inside; if text is actually selected, this changes to "Run Selection". This addresses Issue #43. - Amend the "rows affected" string to better reflect the actual number of rows altered by several queries, show the query count if > 1, and display the overall execution time of the queries. This addresses Issue #142. - No longer execute blank strings as part of the custom query, preventing errors.
Diffstat (limited to 'Source/SPStringAdditions.m')
-rw-r--r--Source/SPStringAdditions.m45
1 files changed, 45 insertions, 0 deletions
diff --git a/Source/SPStringAdditions.m b/Source/SPStringAdditions.m
index 2916611d..ad6972ce 100644
--- a/Source/SPStringAdditions.m
+++ b/Source/SPStringAdditions.m
@@ -66,6 +66,51 @@
return [numberFormatter stringFromNumber:[NSNumber numberWithFloat:size]];
}
+
+// -------------------------------------------------------------------------------
+// stringForTimeInterval:
+//
+// Returns a human readable version string of the supplied time interval.
+// -------------------------------------------------------------------------------
++ (NSString *)stringForTimeInterval:(float)timeInterval
+{
+ NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
+
+ [numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle];
+
+ if (timeInterval < 1) {
+ timeInterval = (timeInterval * 1000);
+ [numberFormatter setFormat:@"#,##0 ms"];
+
+ return [numberFormatter stringFromNumber:[NSNumber numberWithFloat:timeInterval]];
+ }
+
+ if (timeInterval < 100) {
+ [numberFormatter setFormat:@"#,##0.0 s"];
+
+ return [numberFormatter stringFromNumber:[NSNumber numberWithFloat:timeInterval]];
+ }
+
+ if (timeInterval < 300) {
+ [numberFormatter setFormat:@"#,##0 s"];
+
+ return [numberFormatter stringFromNumber:[NSNumber numberWithFloat:timeInterval]];
+ }
+
+ if (timeInterval < 3600) {
+ timeInterval = (timeInterval / 60);
+ [numberFormatter setFormat:@"#,##0 min"];
+
+ return [numberFormatter stringFromNumber:[NSNumber numberWithFloat:timeInterval]];
+ }
+
+ timeInterval = (timeInterval / 3600);
+ [numberFormatter setFormat:@"#,##0 hours"];
+
+ return [numberFormatter stringFromNumber:[NSNumber numberWithFloat:timeInterval]];
+}
+
+
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
// -------------------------------------------------------------------------------
// componentsSeparatedByCharactersInSet: