为什么 Java 在连续整数上切换似乎在增加情况下运行得更快?

2023-12-08

我正在编写一些需要高度优化的 Java 代码,因为它将在主程序逻辑中的许多点调用的热函数中运行。该代码的一部分涉及乘法double变量由10提升为任意非负数int exponents。获得相乘值的一种快速方法(编辑:但不是最快的方法,请参阅下面的更新 2)是switch on the exponent:

double multiplyByPowerOfTen(final double d, final int exponent) {
   switch (exponent) {
      case 0:
         return d;
      case 1:
         return d*10;
      case 2:
         return d*100;
      // ... same pattern
      case 9:
         return d*1000000000;
      case 10:
         return d*10000000000L;
      // ... same pattern with long literals
      case 18:
         return d*1000000000000000000L;
      default:
         throw new ParseException("Unhandled power of ten " + power, 0);
   }
}

上面注释的省略号表明case int常量继续加 1,所以实际上有 19 个case上面的代码片段中的 s 。因为我不确定我是否真的需要 10 的所有幂case声明10 thru 18,我运行了一些微基准测试,比较了完成 1000 万次操作的时间与此switch声明与switch仅与cases 0 thru 9(与exponent限制为 9 个或更少,以避免破坏精简switch)。我得到了相当令人惊讶的结果(至少对我来说!)switch与更多case语句实际上运行得更快。

为了好玩,我尝试添加更多cases 只返回虚拟值,并发现我可以让开关运行得更快,声明大约 22-27cases(即使在代码运行时这些虚拟案例从未真正被击中)。 (再次,case通过增加先前的值以连续的方式添加case常数由1.)这些执行时间差异并不是非常显着:对于随机exponent之间0 and 10,假人填充switch语句在 1.49 秒内完成 1000 万次执行,而未填充版本则需要 1.54 秒,每次执行总共节省了 5 纳秒。所以,这并不是那种让人们痴迷于填充的事情switch从优化的角度来看,声明值得付出努力。但我仍然觉得奇怪且违反直觉switch不会变慢(或者最多保持恒定O(1)时间)执行更多cases 添加到其中。

switch benchmarking results

这些是我在随机生成的各种限制下运行时获得的结果exponent价值观。我没有将结果一直包含到1为了exponent限制,但曲线的总体形状保持不变,在 12-17 箱标记周围有一个脊,在 18-28 之间有一个谷。所有测试均在 JUnitBenchmarks 中运行,使用随机值的共享容器来确保相同的测试输入。我还按照最长的顺序运行了测试switch语句最短,反之亦然,以尝试消除与顺序相关的测试问题的可能性。如果有人想尝试重现这些结果,我已将我的测试代码放在 github 存储库上。

那么,这是怎么回事?我的架构或微基准构建有一些变幻莫测的地方?或者是Javaswitch执行速度确实快了一点18 to 28 case范围比它来自11 up to 17?

github 测试仓库“switch-experiment”

UPDATE:我对基准测试库进行了相当多的清理,并在 /results 中添加了一个文本文件,其中包含更广泛的可能输出exponent价值观。我还在测试代码中添加了一个选项,不要抛出Exception from default,但这似乎并不影响结果。

更新2:在 2009 年的 xkcd 论坛上发现了一些关于这个问题的很好的讨论:。 OP关于使用的讨论Array.binarySearch()给了我一个基于数组的简单实现上述求幂模式的想法。不需要二分搜索,因为我知道其中的条目array是。它的运行速度似乎比使用的快约 3 倍switch,显然是以牺牲一些控制流为代价的switch提供。该代码也已添加到 github 存储库中。


正如所指出的通过另一个答案,因为 case 值是连续的(而不是稀疏的),所以为各种测试生成的字节码使用开关表(字节码指令tableswitch).

然而,一旦 JIT 开始工作并将字节码编译成汇编,tableswitch指令并不总是产生指针数组:有时开关表被转换成看起来像lookupswitch(类似于if/else if结构)。

反编译JIT(热点JDK 1.7)生成的程序集发现,当数量在17个或更少时,它使用了一系列的if/else if,当数量超过18个时,它使用了一个指针数组(效率更高)。

使用这个神奇数字 18 的原因似乎可以归结为MinJumpTableSizeJVM 标志(代码中第 352 行左右)。

我已经在热点编译器列表上提出了这个问题并且这似乎是过去测试的遗产。注意这个默认值已在 JDK 8 中删除 after 进行了更多基准测试.

最后,当方法变得太长时(在我的测试中超过 25 个案例),它不再使用默认 JVM 设置内联 - 这是此时性能下降的最可能原因。


有 5 种情况,反编译代码如下所示(注意 cmp/je/jg/jmp 指令,if/goto 的汇编):

[Verified Entry Point]
  # {method} 'multiplyByPowerOfTen' '(DI)D' in 'javaapplication4/Test1'
  # parm0:    xmm0:xmm0   = double
  # parm1:    rdx       = int
  #           [sp+0x20]  (sp of caller)
  0x00000000024f0160: mov    DWORD PTR [rsp-0x6000],eax
                                                ;   {no_reloc}
  0x00000000024f0167: push   rbp
  0x00000000024f0168: sub    rsp,0x10           ;*synchronization entry
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@-1 (line 56)
  0x00000000024f016c: cmp    edx,0x3
  0x00000000024f016f: je     0x00000000024f01c3
  0x00000000024f0171: cmp    edx,0x3
  0x00000000024f0174: jg     0x00000000024f01a5
  0x00000000024f0176: cmp    edx,0x1
  0x00000000024f0179: je     0x00000000024f019b
  0x00000000024f017b: cmp    edx,0x1
  0x00000000024f017e: jg     0x00000000024f0191
  0x00000000024f0180: test   edx,edx
  0x00000000024f0182: je     0x00000000024f01cb
  0x00000000024f0184: mov    ebp,edx
  0x00000000024f0186: mov    edx,0x17
  0x00000000024f018b: call   0x00000000024c90a0  ; OopMap{off=48}
                                                ;*new  ; - javaapplication4.Test1::multiplyByPowerOfTen@72 (line 83)
                                                ;   {runtime_call}
  0x00000000024f0190: int3                      ;*new  ; - javaapplication4.Test1::multiplyByPowerOfTen@72 (line 83)
  0x00000000024f0191: mulsd  xmm0,QWORD PTR [rip+0xffffffffffffffa7]        # 0x00000000024f0140
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@52 (line 62)
                                                ;   {section_word}
  0x00000000024f0199: jmp    0x00000000024f01cb
  0x00000000024f019b: mulsd  xmm0,QWORD PTR [rip+0xffffffffffffff8d]        # 0x00000000024f0130
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@46 (line 60)
                                                ;   {section_word}
  0x00000000024f01a3: jmp    0x00000000024f01cb
  0x00000000024f01a5: cmp    edx,0x5
  0x00000000024f01a8: je     0x00000000024f01b9
  0x00000000024f01aa: cmp    edx,0x5
  0x00000000024f01ad: jg     0x00000000024f0184  ;*tableswitch
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@1 (line 56)
  0x00000000024f01af: mulsd  xmm0,QWORD PTR [rip+0xffffffffffffff81]        # 0x00000000024f0138
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@64 (line 66)
                                                ;   {section_word}
  0x00000000024f01b7: jmp    0x00000000024f01cb
  0x00000000024f01b9: mulsd  xmm0,QWORD PTR [rip+0xffffffffffffff67]        # 0x00000000024f0128
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@70 (line 68)
                                                ;   {section_word}
  0x00000000024f01c1: jmp    0x00000000024f01cb
  0x00000000024f01c3: mulsd  xmm0,QWORD PTR [rip+0xffffffffffffff55]        # 0x00000000024f0120
                                                ;*tableswitch
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@1 (line 56)
                                                ;   {section_word}
  0x00000000024f01cb: add    rsp,0x10
  0x00000000024f01cf: pop    rbp
  0x00000000024f01d0: test   DWORD PTR [rip+0xfffffffffdf3fe2a],eax        # 0x0000000000430000
                                                ;   {poll_return}
  0x00000000024f01d6: ret    

对于 18 种情况,程序集如下所示(注意所使用的指针数组并抑制了所有比较的需要:jmp QWORD PTR [r8+r10*1]直接跳转到正确的乘法) - 这可能是性能提高的原因:

[Verified Entry Point]
  # {method} 'multiplyByPowerOfTen' '(DI)D' in 'javaapplication4/Test1'
  # parm0:    xmm0:xmm0   = double
  # parm1:    rdx       = int
  #           [sp+0x20]  (sp of caller)
  0x000000000287fe20: mov    DWORD PTR [rsp-0x6000],eax
                                                ;   {no_reloc}
  0x000000000287fe27: push   rbp
  0x000000000287fe28: sub    rsp,0x10           ;*synchronization entry
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@-1 (line 56)
  0x000000000287fe2c: cmp    edx,0x13
  0x000000000287fe2f: jae    0x000000000287fe46
  0x000000000287fe31: movsxd r10,edx
  0x000000000287fe34: shl    r10,0x3
  0x000000000287fe38: movabs r8,0x287fd70       ;   {section_word}
  0x000000000287fe42: jmp    QWORD PTR [r8+r10*1]  ;*tableswitch
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@1 (line 56)
  0x000000000287fe46: mov    ebp,edx
  0x000000000287fe48: mov    edx,0x31
  0x000000000287fe4d: xchg   ax,ax
  0x000000000287fe4f: call   0x00000000028590a0  ; OopMap{off=52}
                                                ;*new  ; - javaapplication4.Test1::multiplyByPowerOfTen@202 (line 96)
                                                ;   {runtime_call}
  0x000000000287fe54: int3                      ;*new  ; - javaapplication4.Test1::multiplyByPowerOfTen@202 (line 96)
  0x000000000287fe55: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe8b]        # 0x000000000287fce8
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@194 (line 92)
                                                ;   {section_word}
  0x000000000287fe5d: jmp    0x000000000287ff16
  0x000000000287fe62: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe86]        # 0x000000000287fcf0
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@188 (line 90)
                                                ;   {section_word}
  0x000000000287fe6a: jmp    0x000000000287ff16
  0x000000000287fe6f: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe81]        # 0x000000000287fcf8
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@182 (line 88)
                                                ;   {section_word}
  0x000000000287fe77: jmp    0x000000000287ff16
  0x000000000287fe7c: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe7c]        # 0x000000000287fd00
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@176 (line 86)
                                                ;   {section_word}
  0x000000000287fe84: jmp    0x000000000287ff16
  0x000000000287fe89: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe77]        # 0x000000000287fd08
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@170 (line 84)
                                                ;   {section_word}
  0x000000000287fe91: jmp    0x000000000287ff16
  0x000000000287fe96: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe72]        # 0x000000000287fd10
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@164 (line 82)
                                                ;   {section_word}
  0x000000000287fe9e: jmp    0x000000000287ff16
  0x000000000287fea0: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe70]        # 0x000000000287fd18
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@158 (line 80)
                                                ;   {section_word}
  0x000000000287fea8: jmp    0x000000000287ff16
  0x000000000287feaa: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe6e]        # 0x000000000287fd20
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@152 (line 78)
                                                ;   {section_word}
  0x000000000287feb2: jmp    0x000000000287ff16
  0x000000000287feb4: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe24]        # 0x000000000287fce0
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@146 (line 76)
                                                ;   {section_word}
  0x000000000287febc: jmp    0x000000000287ff16
  0x000000000287febe: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe6a]        # 0x000000000287fd30
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@140 (line 74)
                                                ;   {section_word}
  0x000000000287fec6: jmp    0x000000000287ff16
  0x000000000287fec8: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe68]        # 0x000000000287fd38
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@134 (line 72)
                                                ;   {section_word}
  0x000000000287fed0: jmp    0x000000000287ff16
  0x000000000287fed2: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe66]        # 0x000000000287fd40
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@128 (line 70)
                                                ;   {section_word}
  0x000000000287feda: jmp    0x000000000287ff16
  0x000000000287fedc: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe64]        # 0x000000000287fd48
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@122 (line 68)
                                                ;   {section_word}
  0x000000000287fee4: jmp    0x000000000287ff16
  0x000000000287fee6: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe62]        # 0x000000000287fd50
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@116 (line 66)
                                                ;   {section_word}
  0x000000000287feee: jmp    0x000000000287ff16
  0x000000000287fef0: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe60]        # 0x000000000287fd58
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@110 (line 64)
                                                ;   {section_word}
  0x000000000287fef8: jmp    0x000000000287ff16
  0x000000000287fefa: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe5e]        # 0x000000000287fd60
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@104 (line 62)
                                                ;   {section_word}
  0x000000000287ff02: jmp    0x000000000287ff16
  0x000000000287ff04: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe5c]        # 0x000000000287fd68
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@98 (line 60)
                                                ;   {section_word}
  0x000000000287ff0c: jmp    0x000000000287ff16
  0x000000000287ff0e: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe12]        # 0x000000000287fd28
                                                ;*tableswitch
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@1 (line 56)
                                                ;   {section_word}
  0x000000000287ff16: add    rsp,0x10
  0x000000000287ff1a: pop    rbp
  0x000000000287ff1b: test   DWORD PTR [rip+0xfffffffffd9b00df],eax        # 0x0000000000230000
                                                ;   {poll_return}
  0x000000000287ff21: ret    

最后,包含 30 个案例的组件(下图)看起来与 18 个案例相似,除了额外的movapd xmm0,xmm1出现在代码中间,正如@cHao 发现的- 然而,性能下降的最可能原因是该方法太长,无法内联到默认的 JVM 设置:

[Verified Entry Point]
  # {method} 'multiplyByPowerOfTen' '(DI)D' in 'javaapplication4/Test1'
  # parm0:    xmm0:xmm0   = double
  # parm1:    rdx       = int
  #           [sp+0x20]  (sp of caller)
  0x0000000002524560: mov    DWORD PTR [rsp-0x6000],eax
                                                ;   {no_reloc}
  0x0000000002524567: push   rbp
  0x0000000002524568: sub    rsp,0x10           ;*synchronization entry
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@-1 (line 56)
  0x000000000252456c: movapd xmm1,xmm0
  0x0000000002524570: cmp    edx,0x1f
  0x0000000002524573: jae    0x0000000002524592  ;*tableswitch
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@1 (line 56)
  0x0000000002524575: movsxd r10,edx
  0x0000000002524578: shl    r10,0x3
  0x000000000252457c: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe3c]        # 0x00000000025243c0
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@364 (line 118)
                                                ;   {section_word}
  0x0000000002524584: movabs r8,0x2524450       ;   {section_word}
  0x000000000252458e: jmp    QWORD PTR [r8+r10*1]  ;*tableswitch
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@1 (line 56)
  0x0000000002524592: mov    ebp,edx
  0x0000000002524594: mov    edx,0x31
  0x0000000002524599: xchg   ax,ax
  0x000000000252459b: call   0x00000000024f90a0  ; OopMap{off=64}
                                                ;*new  ; - javaapplication4.Test1::multiplyByPowerOfTen@370 (line 120)
                                                ;   {runtime_call}
  0x00000000025245a0: int3                      ;*new  ; - javaapplication4.Test1::multiplyByPowerOfTen@370 (line 120)
  0x00000000025245a1: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe27]        # 0x00000000025243d0
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@358 (line 116)
                                                ;   {section_word}
  0x00000000025245a9: jmp    0x0000000002524744
  0x00000000025245ae: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe22]        # 0x00000000025243d8
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@348 (line 114)
                                                ;   {section_word}
  0x00000000025245b6: jmp    0x0000000002524744
  0x00000000025245bb: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe1d]        # 0x00000000025243e0
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@338 (line 112)
                                                ;   {section_word}
  0x00000000025245c3: jmp    0x0000000002524744
  0x00000000025245c8: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe18]        # 0x00000000025243e8
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@328 (line 110)
                                                ;   {section_word}
  0x00000000025245d0: jmp    0x0000000002524744
  0x00000000025245d5: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe13]        # 0x00000000025243f0
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@318 (line 108)
                                                ;   {section_word}
  0x00000000025245dd: jmp    0x0000000002524744
  0x00000000025245e2: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe0e]        # 0x00000000025243f8
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@308 (line 106)
                                                ;   {section_word}
  0x00000000025245ea: jmp    0x0000000002524744
  0x00000000025245ef: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe09]        # 0x0000000002524400
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@298 (line 104)
                                                ;   {section_word}
  0x00000000025245f7: jmp    0x0000000002524744
  0x00000000025245fc: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe04]        # 0x0000000002524408
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@288 (line 102)
                                                ;   {section_word}
  0x0000000002524604: jmp    0x0000000002524744
  0x0000000002524609: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffdff]        # 0x0000000002524410
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@278 (line 100)
                                                ;   {section_word}
  0x0000000002524611: jmp    0x0000000002524744
  0x0000000002524616: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffdfa]        # 0x0000000002524418
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@268 (line 98)
                                                ;   {section_word}
  0x000000000252461e: jmp    0x0000000002524744
  0x0000000002524623: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffd9d]        # 0x00000000025243c8
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@258 (line 96)
                                                ;   {section_word}
  0x000000000252462b: jmp    0x0000000002524744
  0x0000000002524630: movapd xmm0,xmm1
  0x0000000002524634: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffe0c]        # 0x0000000002524448
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@242 (line 92)
                                                ;   {section_word}
  0x000000000252463c: jmp    0x0000000002524744
  0x0000000002524641: movapd xmm0,xmm1
  0x0000000002524645: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffddb]        # 0x0000000002524428
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@236 (line 90)
                                                ;   {section_word}
  0x000000000252464d: jmp    0x0000000002524744
  0x0000000002524652: movapd xmm0,xmm1
  0x0000000002524656: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffdd2]        # 0x0000000002524430
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@230 (line 88)
                                                ;   {section_word}
  0x000000000252465e: jmp    0x0000000002524744
  0x0000000002524663: movapd xmm0,xmm1
  0x0000000002524667: mulsd  xmm0,QWORD PTR [rip+0xfffffffffffffdc9]        # 0x0000000002524438
                                                ;*dmul
                                                ; - javaapplication4.Test1::multiplyByPowerOfTen@224 (line 86)
                                                ;   {section_word}

[etc.]

  0x0000000002524744: add    rsp,0x10
  0x0000000002524748: pop    rbp
  0x0000000002524749: test   DWORD PTR [rip+0xfffffffffde1b8b1],eax        # 0x0000000000340000
                                                ;   {poll_return}
  0x000000000252474f: ret    
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

为什么 Java 在连续整数上切换似乎在增加情况下运行得更快? 的相关文章

随机推荐

  • 在android中的谷歌地图上绘制多个标记

    我是android领域的新手 我写了一个安卓应用1将从网络提供商检索纬度和经度值并将其存储在我的本地服务器 LAMP 中 我还创建了一个 MYSQL DB 表 该表有 3 列 lat lon id 其中包含使用网络提供程序检索的值 lat
  • 为什么即使没有任何类声明也需要原型?

    如果我只是这样做 Ex1 include
  • 为什么我会收到 301 重定向到带有斜杠的文件夹名称?

    请求http localhost SAMPLE CODES backbone mysql reading json websites 被重定向如下 gt Request URL http localhost SAMPLE CODES bac
  • 单选按钮 onclick 不起作用

    我有 3 个单选按钮 将根据单击的按钮显示列表中的某些作业 我曾经使用搜索按钮来运行搜索代码 因此 用户将选择一个单选按钮 然后单击搜索 但现在我已经删除了搜索按钮 我希望单选按钮在单击时调用搜索功能 table tr td td tr t
  • 如何使用 Byte Buddy 更改导入?

    我想更改类的导入 以便它们指向不同的包 Byte Buddy 文档没有提供太多关于如何实现这一目标的信息 这是我到目前为止所拥有的 public class ProxyPlugin implements net bytebuddy buil
  • 限时输入? [复制]

    这个问题在这里已经有答案了 我希望能够做的是使用输入向用户询问问题 例如 print some scenario prompt input You have 10 seconds to choose the correct answer n
  • 使用 fileConfig 在 Python 中配置自定义处理程序

    我正在使用配置文件在 Python 应用程序中配置我的记录器 这是文件 loggers keys root logger root level INFO handlers console handlers keys console file
  • 在 SSRS 中分组?

    我是 SSRS 的新手 数据如下所示 它们都来自同一个数据集 就像将 2 列分组一样 即 WrkCrtId Name 显示在它们之上 我已经尝试了一些方法来做到这一点 但仍然失败 我想知道是否有人可以提供帮助 附注下图显示了 2 组 B3
  • 在.NET 6控制台应用程序中读取appsettings.json文件

    如何从appsettings json NET 6 控制台应用程序中的文件 program cs file public class Program private static ManualResetEvent quitEvent new
  • 如何在 Ant 中从逗号分隔的目录列表创建文件集?

    在 Ant 目标中 我获得一个属性 其中包含要包含在进一步操作 复制 过滤等 中的目录列表 它看起来像这样 directories dir1 dir2 dir3 我需要一种方法将此列表转换为选择的文件集或模式集all这些目录中的文件 我知道
  • 转换错误:需要左值作为赋值的左操作数

    所以我正在尝试使用ether aton 它返回一个struct ether addr 我正在尝试将其放入我的struct ether header eptr 来自 net ethernet h ether shost成员 我试过这个 str
  • swift3 日期到数据,数据到日期转换

    我正在努力将 Objective C 中创建的代码更改为 swift3 我想将下面的代码更改为使用 Objective c 创建的 swift3 代码 Objective c NSDate 到 NSData 代码 NSCalendar ca
  • 如何使用 PDFBox 对动态创建的 PDF 文档进行数字签名?

    对不起 我java很差 我哪里不对的地方请指正 我哪里不好的地方请改进 我正在尝试使用 PDFBox 通过以下程序对动态创建的 pdf 进行数字签名 计划中的任务 i 创建 PDF 模板 ii 更新 ByteRange xref start
  • 如何在构建阶段使用其他小部件的约束和大小

    我想确保涵盖所有情况 父窗口小部件读取 并可能使用 子窗口的大小或约束 子部件读取 并可能使用 父部件的大小或约束 子部件读取 并可能使用 另一个子部件的大小或约束 解决方案似乎是 让构建阶段运行 然后构建我想要从中检索数据的小部件的大小和
  • 本地通知?

    我的应用程序主要是服务器的客户端 实际上没有连接到互联网 它连接到 Polycom 编解码器并管理 2 个端点之间的视频通话 所以我的应用程序可以发送诸如结束通话 调高音量等命令 然而我的问题是这样的 当有来电并且应用程序不在前台时 我需要
  • Next.js Firebase 托管 404 错误(除 index.html 外)

    我构建了一个 nextjs 应用程序npm run build npm run export并使用部署到 firebasefirebase deploy命令 在此之前 我曾经使用过firebase init在我的项目文件夹中 仅使用默认选项
  • 如何将电子邮件建议传递到 Azure AD B2C 注册页面

    有没有办法在自定义策略中建议注册电子邮件 我的一些用户只需要通过邀请电子邮件进行注册 我在文档中看到 https learn microsoft com bs latn ba azure active directory b2c direc
  • ViewStateUserKey + 共享托管 + ViewStateMac 验证失败

    所以 问题很简单 尽管我开始怀疑这是否会得到解答 我有一个网站 我想在其中使用推荐的 ViewStateUserKey 来保护我的视图状态 在我的基页 显然继承自 Page 中 我有以下代码 protected override void
  • 保留最新文件并删除所有其他文件

    在我的文件夹中有许多具有日期时间戳格式的 pdf 文件 如最后所示 我想保留当天的最新文件并删除当天的其余文件 我该怎么做 2012 07 13 15 13 27 1342167207 pdf 2012 07 13 15 18 22 134
  • 为什么 Java 在连续整数上切换似乎在增加情况下运行得更快?

    我正在编写一些需要高度优化的 Java 代码 因为它将在主程序逻辑中的许多点调用的热函数中运行 该代码的一部分涉及乘法double变量由10提升为任意非负数int exponents 获得相乘值的一种快速方法 编辑 但不是最快的方法 请参阅