|
9 | 9 |
|
10 | 10 | // TODO: still a lot of references to window[...] |
11 | 11 |
|
| 12 | +// BH 1/8/2019 3.2.4.07 fixes String.prototype.to[Upper|Lower]Case$java_util_Locale - using toLocal[Upper|Lower]Case() |
12 | 13 | // BH 1/3/2019 3.2.4.07 adds ByteBuffer/CharBuffer support, proper CharSet encoding, including GBK (Standard Chinese) |
13 | 14 |
|
14 | 15 | // see earlier notes at net.sf.j2s.java.core.srcjs/js/devnotes.txt |
@@ -834,82 +835,51 @@ Clazz.setConsoleDiv = function(d) { |
834 | 835 | // which could be a bottle-neck for function calling. |
835 | 836 | // This is critical for performance optimization. |
836 | 837 |
|
837 | | -var _profile = null; |
838 | | -var _profileNoOpt = false; // setting this true will remove Bob's signature optimization |
839 | | - |
840 | 838 | var __signatures = ""; |
841 | 839 | var profilet0; |
842 | 840 | var _profileNew = null; |
843 | 841 | var _jsid0 = 0; |
844 | 842 |
|
845 | 843 | Clazz.startProfiling = function(doProfile) { |
| 844 | + _profileNew = {}; |
846 | 845 | if (typeof doProfile == "number") { |
847 | | - _profileNew = (arguments[1] ? {} : null); |
848 | 846 | _jsid0 = _jsid; |
849 | 847 | setTimeout(function() { var s = "total wall time: " + doProfile + " sec\n" + Clazz.getProfile(); console.log(s); System.out.println(s)}, doProfile * 1000); |
| 848 | + } else if (!doProfile) { |
| 849 | + _jsid = 0; |
| 850 | + _profileNew = null; |
850 | 851 | } |
851 | | - _profile = ((doProfile || arguments.length == 0) && self.JSON && window.performance ? {} : null); |
852 | | - return (_profile ? "use Clazz.getProfile() to show results" : "profiling stopped and cleared") |
| 852 | + return (_profileNew ? "use Clazz.getProfile() to show results" : "profiling stopped and cleared") |
853 | 853 | } |
854 | 854 |
|
855 | 855 | var tabN = function(n) { n = ("" + n).split(".")[0]; return "..........".substring(n.length) + n + "\t" }; |
856 | 856 |
|
857 | 857 | Clazz.getProfile = function() { |
858 | 858 | var s = "run Clazz.startProfiling() first"; |
859 | | - if (_profile) { |
860 | | - var l = []; |
861 | | - var totalcount = 0; |
862 | | - var totalprep = 0; |
863 | | - var totaltime = 0; |
864 | | - for (var name in _profile) { |
865 | | - var n = _profile[name][0]; |
866 | | - var t1 = _profile[name][1]; |
867 | | - var t2 = _profile[name][2]; |
868 | | - l.push(tabN(n) + tabN(t1) + tabN(t2) + name); |
869 | | - totalcount += n |
870 | | - totalprep += t1 |
871 | | - totaltime += t2 |
872 | | - } |
873 | | - s = "\ncount \tprep(ms)\texec(ms)\n" |
874 | | - + "--------\t--------\t--------\n" |
875 | | - + tabN(totalcount)+ tabN(totalprep)+tabN(totaltime) + "\n" |
876 | | - + "--------\t--------\t--------\n" |
877 | | - + l.sort().reverse().join("\n") |
878 | | - ; |
879 | | - _profile = null; |
880 | 859 |
|
881 | 860 | if (_profileNew) { |
882 | 861 | s += "\n\n Total new objects: " + (_jsid - _jsid0) + "\n"; |
883 | 862 | s += "\ncount \texec(ms)\n"; |
884 | 863 | s += "--------\t--------\t------------------------------\n"; |
885 | 864 | totalcount = 0; |
886 | 865 | totaltime = 0; |
| 866 | + var rows = []; |
887 | 867 | for (var key in _profileNew) { |
888 | 868 | var count = _profileNew[key][0]; |
889 | 869 | var tnano = _profileNew[key][1]; |
890 | | - totalcount += count |
891 | | - totaltime += tnano |
892 | | - s += tabN(count) + tabN(tnano) + "\t" +key + "\n"; |
| 870 | + totalcount += count; |
| 871 | + totaltime += tnano; |
| 872 | + rows.push(tabN(count) + tabN(tnano) + "\t" +key + "\n"); |
893 | 873 | } |
894 | | - s+= tabN(totalcount)+tabN(totaltime) + "\n" |
| 874 | + rows.sort(); |
| 875 | + rows.reverse(); |
| 876 | + s += rows.join(""); |
| 877 | + s+= tabN(totalcount)+tabN(totaltime) + "\n"; |
895 | 878 | } |
896 | | - } |
897 | 879 | _profileNew = null; |
898 | 880 | return s; //+ __signatures; |
899 | 881 | } |
900 | 882 |
|
901 | | - |
902 | | -var addProfile = function(c, f, p, t1, t2) { |
903 | | - var s = c.__CLASS_NAME__ + " " + f + " ";// + JSON.stringify(p); |
904 | | - if (__signatures.indexOf(s) < 0) |
905 | | - __signatures += s + "\n"; |
906 | | - var p = _profile[s]; |
907 | | - p || (p = _profile[s] = [0,0,0]); |
908 | | - p[0]++; |
909 | | - p[1] += t1; |
910 | | - p[2] += t2; |
911 | | -} |
912 | | - |
913 | 883 | var addProfileNew = function(c, t) { |
914 | 884 | var s = c.__CLASS_NAME__; |
915 | 885 | var p = _profileNew[s]; |
@@ -4585,10 +4555,11 @@ sp.charCodeAt$I = sp.charCodeAt; |
4585 | 4555 | sp.charAt$I = sp.charAt; |
4586 | 4556 | sp.substring$I = sp.substring$I$I = sp.subSequence$I$I = sp.substring; |
4587 | 4557 | sp.replace$C$C = sp.replace$CharSequence$CharSequence = sp.replace$; |
4588 | | -sp.toUpperCase$ = sp.toUpperCase$java_util_locale = sp.toUpperCase; |
4589 | | -sp.toLowerCase$ = sp.toLowerCase$java_util_locale = sp.toLowerCase; |
| 4558 | +sp.toUpperCase$ = sp.toUpperCase; |
| 4559 | +sp.toLowerCase$ = sp.toLowerCase; |
4590 | 4560 | sp.trim$ = sp.trim; |
4591 | | - |
| 4561 | +sp.toLowerCase$java_util_Locale = sp.toLocaleLowerCase ? function(loc) {return this.valueOf().toLocaleLowerCase(loc.toString()) } : sp.toLowerCase; |
| 4562 | +sp.toUpperCase$java_util_Locale = sp.toLocaleUpperCase ? function(loc) {return this.valueOf().toLocaleUpperCase(loc.toString()) } : sp.toUpperCase; |
4592 | 4563 | sp.length$ = function() {return this.length}; |
4593 | 4564 |
|
4594 | 4565 | //sp.chars$ = CharSequence.prototype.chars$; |
|
0 commit comments