Skip to content

Commit 08abd98

Browse files
author
Paradiseduo
committed
性能优化
1 parent f84e8e8 commit 08abd98

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tcping/main.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ int main(int argc, const char * argv[]) {
9898
}
9999
dispatch_group_notify(group, dispatch_get_main_queue(), ^{
100100
if (sockets.count > 0) {
101-
NSMutableArray<Tcping *> * successArray = [[NSMutableArray alloc] init];
101+
NSInteger successCount = 0;
102102
NSTimeInterval min = INFINITY;
103103
NSTimeInterval max = 0;
104104
NSTimeInterval sum = 0;
105105
for (Tcping * t in sockets) {
106106
if (t.speed != INFINITY) {
107-
[successArray addObject:t];
107+
successCount += 1;
108108
if (t.speed > max) {
109109
max = t.speed;
110110
}
@@ -114,11 +114,11 @@ int main(int argc, const char * argv[]) {
114114
sum += t.speed;
115115
}
116116
}
117-
if (successArray.count == 0) {
117+
if (successCount == 0) {
118118
[ConsoleIO printReulst:YES detail:sockets[0] count:sockets.count lossCount:sockets.count min:[NSNumber numberWithDouble:min] max:[NSNumber numberWithDouble:max] avge:[NSNumber numberWithDouble:INFINITY]];
119119
} else {
120-
double s = successArray.count*1.0;
121-
[ConsoleIO printReulst:YES detail:sockets[0] count:sockets.count lossCount:sockets.count-successArray.count min:[NSNumber numberWithDouble:min] max:[NSNumber numberWithDouble:max] avge:[NSNumber numberWithDouble:sum/s]];
120+
double s = successCount*1.0;
121+
[ConsoleIO printReulst:YES detail:sockets[0] count:sockets.count lossCount:sockets.count-successCount min:[NSNumber numberWithDouble:min] max:[NSNumber numberWithDouble:max] avge:[NSNumber numberWithDouble:sum/s]];
122122
}
123123
running = NO;
124124
}

0 commit comments

Comments
 (0)