• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Camelcade / Perl5-IDEA / #525521810

09 Apr 2026 07:50PM UTC coverage: 75.982% (+0.003%) from 75.979%
#525521810

push

github

hurricup
Build 2026.2-EAP.3395

14764 of 22624 branches covered (65.26%)

Branch coverage included in aggregate %.

31089 of 37723 relevant lines covered (82.41%)

0.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

68.63
/plugin/common/src/main/java/com/perl5/lang/perl/util/PerlTimeLogger.java
1
/*
2
 * Copyright 2015-2026 Alexandr Evstigneev
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
package com.perl5.lang.perl.util;
18

19
import com.intellij.openapi.diagnostic.Logger;
20
import org.jetbrains.annotations.NotNull;
21
import org.jetbrains.annotations.Nullable;
22

23
import java.util.HashMap;
24
import java.util.Map;
25

26
public class PerlTimeLogger {
27
  private static final PerlTimeLogger EMPTY_LOGGER = new PerlTimeLogger("") {
1✔
28
    @Override
29
    public void debug(@NotNull Object... data) {
30
    }
×
31

32
    @Override
33
    public @NotNull Counter getCounter(@NotNull String name) {
34
      return Counter.EMPTY_COUNTER;
×
35
    }
36
  };
37

38
  private final Logger myLogger;
39
  long myLastTime = System.currentTimeMillis();
1✔
40
  private Map<String, Counter> myCounters;
41

42
  public PerlTimeLogger(@NotNull String id) {
1✔
43
    myLogger = Logger.getInstance(id);
1✔
44
  }
1✔
45

46
  public PerlTimeLogger(@NotNull Logger logger) {
1✔
47
    myLogger = logger;
1✔
48
  }
1✔
49

50
  public void debug(@NotNull Object... data) {
51
    if (myLogger.isDebugEnabled()) {
1!
52
      long newLastTime = System.currentTimeMillis();
1✔
53
      //noinspection LoggingSimilarMessage
54
      myLogger.debug((newLastTime - myLastTime) + " ms. ", data);
1✔
55
      myLastTime = newLastTime;
1✔
56
    }
57
  }
1✔
58

59
  public void trace(@NotNull Object... data) {
60
    if (myLogger.isTraceEnabled()) {
1!
61
      long newLastTime = System.currentTimeMillis();
×
62
      //noinspection LoggingSimilarMessage
63
      myLogger.debug((newLastTime - myLastTime) + " ms. ", data);
×
64
      myLastTime = newLastTime;
×
65
    }
66
  }
1✔
67

68
  public @NotNull Counter getCounter(@NotNull String name) {
69
    if (myCounters == null) {
1✔
70
      myCounters = new HashMap<>();
1✔
71
    }
72
    return myCounters.computeIfAbsent(name, it -> new Counter());
1!
73
  }
74

75
  public static class Counter {
1✔
76
    private static final Counter EMPTY_COUNTER = new Counter() {
1✔
77
      @Override
78
      public void inc() {
79
      }
×
80

81
      @Override
82
      public int get() {
83
        return 0;
×
84
      }
85
    };
86

87
    private int myCounter = 0;
1✔
88

89
    public void inc() {
90
      myCounter++;
1✔
91
    }
1✔
92

93
    public int get() {
94
      return myCounter;
1✔
95
    }
96
  }
97

98
  public static @NotNull String kb(int bytes) {
99
    return String.format("%.2f", (float)bytes / 1024);
1!
100
  }
101

102
  public static @NotNull PerlTimeLogger create(@Nullable Logger logger) {
103
    return logger != null && logger.isDebugEnabled() ? new PerlTimeLogger(logger) : EMPTY_LOGGER;
1!
104
  }
105
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc