Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

76
LINES

< > BotCompany Repo | #1025501 // Benchmark & Profile Transpiler

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (12300L/78K).

1  
!7
2  
3  
sS transpilerID = /*#1025804;*/ #759;
4  
5  
p {
6  
  S sRuns = second(args);
7  
  int runs = 12; // 8 wasn't enough to fully compile for smaller sources
8  
  if (isInteger(sRuns)) runs = parseInt(sRuns);
9  
  
10  
  bool mediumTranspile = !cic(args, "quick");
11  
  S snippetID = or2(first(args), #1016478); // transpile the OS by default
12  
  S mainJava =
13  
    //[[print("hello!");]];
14  
    //loadSnippet(#759); // doesn't work, requires different transpiler
15  
    loadSnippet(snippetID);
16  
    
17  
  mainJava = dropTranslators(mainJava);
18  
  
19  
  S transpiled, transpiled2;
20  
  new L<Long> times;
21  
  bool resultsDiffer;
22  
  
23  
  maximizeConsole();
24  
  
25  
  O transpiler = hotwireDependent(transpilerID);
26  
  setAll(transpiler,
27  
    /*useIndexedList2 := false, useTokenIndexedList := true,*/
28  
    dontLoadCachedIncludesFromVM := true,
29  
    //cacheStdFunctions := false,
30  
    //cacheStdClasses := false
31  
  );
32  
    
33  
  time "First run" {
34  
    set(transpiler, +mainJava);
35  
    setOpt(transpiler, mainSnippetID := snippetID);
36  
    callMain(transpiler);
37  
    transpiled = (S) get(transpiler, 'mainJava);
38  
  }
39  
  long time1 = lastTiming();
40  
  
41  
  // Now we should have cached all the snippets, but not the pre-transpiled stuff.
42  
  
43  
  for (int run = 2; run <= runs; run++) {
44  
    S msg = "Run " + run;
45  
    if (run == runs) poorMansProfiling();
46  
    if (run == runs-1) call(transpiler, "clearSnippetCache");
47  
    time msg {
48  
      if (mediumTranspile)
49  
        call(transpiler, 'forgetCachedIncludes);
50  
      set(transpiler, +mainJava);
51  
      setOpt(transpiler, mainSnippetID := snippetID);
52  
      callMain(transpiler);
53  
      transpiled2 = (S) get(transpiler, 'mainJava);
54  
    }
55  
    times.add(lastTiming());
56  
    S check1 = minusLinesContaining("myTranspilationDate_value", transpiled);
57  
    S check2 = minusLinesContaining("myTranspilationDate_value", transpiled2);
58  
    if (neq(check1, check2)) {
59  
      set resultsDiffer;
60  
      print("WARNING: RESULTS DIFFER");
61  
      print(unidiff(check1, check2));
62  
    }
63  
  }
64  
  
65  
  poorMansProfiling_stopAndPrintResults();
66  
  
67  
  print("Made " + nChars(transpiled) + ", md5: " + md5(transpiled));
68  
  print("Run 1 with downloads: " + time1 + " ms");
69  
  int run = 2;
70  
  for (long time : times) {
71  
    print("Run " + run + " " + (run == runs-1 ? "with" : "w/o") + " downloads: " + time + " ms");
72  
    run++;
73  
  }
74  
  if (resultsDiffer)
75  
    print("WARNING: RESULTS DIFFER BETWEEN RUNS");
76  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 11 computer(s): bhatertpkbcr, jcllbfdqhrgy, mqqgnosmbjvj, omdjrrnzbjjv, pyentgdyhuwx, pzhvpgtvlbxg, snaazhdonpnp, tvejysmllsmz, vouqrxazstgt, whxojlpjdney, xrpafgyirdlv

No comments. add comment

Snippet ID: #1025501
Snippet name: Benchmark & Profile Transpiler
Eternal ID of this version: #1025501/41
Text MD5: 0bb866c9f45a703911c77603547cfdd7
Transpilation MD5: ebeebefed0ff29bd3db420c0903f00d8
Author: stefan
Category: javax / transpiling
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-01 20:21:56
Source code size: 2400 bytes / 76 lines
Pitched / IR pitched: No / No
Views / Downloads: 428 / 1869
Version history: 40 change(s)
Referenced in: [show references]