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

Camelcade / Perl5-IDEA / #525521583

06 Jun 2025 03:47PM UTC coverage: 82.349% (+0.02%) from 82.33%
#525521583

push

github

hurricup
Qodana baseline update

30862 of 37477 relevant lines covered (82.35%)

0.82 hits per line

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

92.86
/plugin/profiler/src/main/java/com/perl5/lang/perl/profiler/run/PerlProfilerRunProfileState.java
1
/*
2
 * Copyright 2015-2025 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.profiler.run;
18

19
import com.intellij.execution.ExecutionException;
20
import com.intellij.execution.runners.ExecutionEnvironment;
21
import com.intellij.openapi.application.PathManager;
22
import com.intellij.openapi.projectRoots.Sdk;
23
import com.intellij.openapi.util.io.FileUtil;
24
import com.intellij.openapi.util.text.StringUtil;
25
import com.perl5.lang.perl.idea.project.PerlProjectManager;
26
import com.perl5.lang.perl.idea.run.GenericPerlRunConfiguration;
27
import com.perl5.lang.perl.idea.run.PerlRunProfileState;
28
import com.perl5.lang.perl.idea.sdk.host.PerlHostData;
29
import com.perl5.lang.perl.profiler.PerlProfilerBundle;
30
import com.perl5.lang.perl.profiler.configuration.PerlProfilerConfigurationState;
31
import org.jetbrains.annotations.NotNull;
32

33
import java.io.File;
34
import java.nio.file.Path;
35
import java.nio.file.Paths;
36
import java.util.Collections;
37
import java.util.List;
38
import java.util.Map;
39

40
public class PerlProfilerRunProfileState extends PerlRunProfileState {
41
  private final @NotNull PerlProfilerConfigurationState myProfilerConfigurationState;
42
  public static final String BASE_DUMP_NAME = "nytprof.out";
43

44
  public PerlProfilerRunProfileState(@NotNull ExecutionEnvironment environment,
45
                                     @NotNull PerlProfilerConfigurationState profilerConfigurationState) {
46
    super(environment);
1✔
47
    myProfilerConfigurationState = profilerConfigurationState;
1✔
48
  }
1✔
49

50
  public @NotNull PerlProfilerConfigurationState getProfilerConfigurationState() {
51
    return myProfilerConfigurationState;
1✔
52
  }
53

54
  public final @NotNull Path getProfilingResultsPath() {
55
    var project = getEnvironment().getProject();
1✔
56
    var perlSdk = PerlProjectManager.getSdk(project);
1✔
57
    return Paths.get(PathManager.getSystemPath(),
1✔
58
                     "profiling",
59
                     FileUtil.sanitizeFileName(
1✔
60
                       String.join("_", project.getName(),
1✔
61
                                   perlSdk == null ? "null" : perlSdk.getName(),
1✔
62
                                   StringUtil.notNullize(myProfilerConfigurationState.getDisplayName(), "unnamed"),
1✔
63
                                   getEnvironment().getRunProfile().getName()
1✔
64
                       )));
65
  }
66

67
  public @NotNull File getDumpFile() {
68
    var profileResultsPath = getProfilingResultsPath();
1✔
69
    profileResultsPath.toFile().mkdirs();
1✔
70
    return profileResultsPath.resolve(BASE_DUMP_NAME).toFile();
1✔
71
  }
72

73
  @Override
74
  public @NotNull List<String> getAdditionalPerlArguments(@NotNull GenericPerlRunConfiguration perlRunConfiguration) {
75
    return Collections.singletonList("-d:NYTProf");
1✔
76
  }
77

78
  @Override
79
  public Map<String, String> getAdditionalEnvironmentVariables() throws ExecutionException {
80
    Sdk effectiveSdk = ((GenericPerlRunConfiguration)getEnvironment().getRunProfile()).getEffectiveSdk();
1✔
81
    PerlHostData<?, ?> hostData = PerlHostData.notNullFrom(effectiveSdk);
1✔
82
    var dumpLocalPath = getDumpFile().getAbsolutePath();
1✔
83
    var remotePath = hostData.getRemotePath(dumpLocalPath);
1✔
84
    if (StringUtil.isEmpty(remotePath)) {
1✔
85
      throw new ExecutionException(PerlProfilerBundle.message("dialog.message.unable.to.compute.remote.path.for", dumpLocalPath));
×
86
    }
87
    var nytProfOptions = "stmts=0:calls=2:savesrc=0:slowops=1:sigexit=1:addpid=1" +
1✔
88
                         ":file=" + StringUtil.escapeChar(FileUtil.toSystemIndependentName(remotePath), ':') +
1✔
89
                         ":start=" + myProfilerConfigurationState.getStartupMode().getProfilerCommand();
1✔
90
    if (myProfilerConfigurationState.isOptimizerDisabled()) {
1✔
91
      nytProfOptions += ":optimize=0";
×
92
    }
93

94
    return Map.of("NYTPROF", nytProfOptions);
1✔
95
  }
96
}
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