Skip to content

Commit

Permalink
perf: improve log, comment some unused logs
Browse files Browse the repository at this point in the history
  • Loading branch information
tisfeng committed Apr 22, 2024
1 parent bfe7747 commit 27a71da
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 14 deletions.
3 changes: 1 addition & 2 deletions Easydict/Swift/Service/Ali/AliService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ class AliService: QueryService {
if let data = value.data, let translateText = data.translated {
result.translatedResults = [translateText]
completion(result, nil)
logInfo("ali api translate success")
} else {
completion(
result,
Expand All @@ -257,7 +256,7 @@ class AliService: QueryService {
msg = error.errorDescription
}

logError("ali api translate error: \(msg ?? "")")
logError("Ali translate error: \(msg ?? "")")
completion(result, EZError(nsError: error, errorDataMessage: msg))
}
}
Expand Down
2 changes: 1 addition & 1 deletion Easydict/Swift/Service/Gemini/GeminiService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public final class GeminiService: QueryService {
do {
let prompt = GeminiService
.translationPrompt + "Translate the following \(from.rawValue) text into \(to.rawValue): \(text)"
logInfo("gemini prompt: \(prompt)")
// logInfo("gemini prompt: \(prompt)")
let model = GenerativeModel(
name: "gemini-pro",
apiKey: apiKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ - (nullable NSString *)queryAllIframeHTMLResultOfWord:(NSString *)word
- (NSArray<NSString *> *)queryEntryHTMLsOfWord:(NSString *)word
inDictionary:(TTTDictionary *)dictionary
language:(nullable EZLanguage)language {
CFAbsoluteTime startTime = CFAbsoluteTimeGetCurrent();
// CFAbsoluteTime startTime = CFAbsoluteTimeGetCurrent();
NSMutableArray *entryHTMLs = [NSMutableArray array];

// Cost about ~10ms
Expand All @@ -270,8 +270,8 @@ - (nullable NSString *)queryAllIframeHTMLResultOfWord:(NSString *)word
}
}

CFAbsoluteTime endTime = CFAbsoluteTimeGetCurrent();
MMLogInfo(@"Query [%@] dict cost: %.1f ms", dictionary.name, (endTime - startTime) * 1000); // 13ms
// CFAbsoluteTime endTime = CFAbsoluteTimeGetCurrent();
// MMLog(@"Query [%@] dict cost: %.1f ms", dictionary.name, (endTime - startTime) * 1000); // 13ms

return entryHTMLs;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@
// Change font size
function changeIframeBodyFontSize(fontSizeRatio) {
var percentFontSize = fontSizeRatio * 100 + "%";
console.log("fontSize: " + fontSizeRatio);
// console.log("fontSize: " + fontSizeRatio);

// change body font size
document.body.style.fontSize = percentFontSize;
Expand Down Expand Up @@ -514,4 +514,4 @@

<body></body>

</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation
// 监听 JavaScript 代码是否执行
- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler {
// JavaScript 代码执行
MMLogError(@"runJavaScriptAlertPanelWithMessage: %@", message);
MMLogInfo(@"runJavaScriptAlertPanelWithMessage: %@", message);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,7 @@ - (BOOL)textView:(NSTextView *)textView doCommandBySelector:(SEL)commandSelector
#pragma mark - WKNavigationDelegate

- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
MMLogInfo(@"webView didFinishNavigation");
// MMLog(@"webView didFinishNavigation");

[self.result.webViewManager updateAllIframe];
}
Expand Down Expand Up @@ -1093,7 +1093,7 @@ - (void)updateWebViewHeight:(CGFloat)scrollHeight {
// Cost ~0.15s
// NSString *script = @"document.documentElement.scrollHeight;";

MMLogInfo(@"scrollHeight: %.1f", scrollHeight);
// MMLog(@"scrollHeight: %.1f", scrollHeight);

CGFloat visibleFrameHeight = EZLayoutManager.shared.screen.visibleFrame.size.height;
CGFloat maxHeight = visibleFrameHeight * 0.55;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1516,12 +1516,11 @@ - (void)autoPlayEnglishWordAudio {
}

BOOL isEnglishWord = [self.queryText isEnglishWordWithLanguage:self.queryModel.queryFromLanguage];

if (!isEnglishWord) {
MMLogWarn(@"Not an English Word");
return;
}

MMLogInfo(@"Auto play English word audio: %@", self.queryText);
[self togglePlayQueryText:YES];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ - (void)windowDidResignKey:(NSNotification *)notification {
}

- (void)windowDidResize:(NSNotification *)aNotification {
MMLogInfo(@"windowDidResize: %@, windowType: %ld", @(self.frame), self.windowType);
// MMLog(@"windowDidResize: %@, windowType: %ld", @(self.frame), self.windowType);

[[EZLayoutManager shared] updateWindowFrame:self];

Expand Down

0 comments on commit 27a71da

Please sign in to comment.