在本文中,我们将为您详细介绍deque.popleft的相关知识,并且为您解答关于和list.pop的疑问,此外,我们还会提供一些关于Arrays.stream()。map()。sum()的不稳定性能
在本文中,我们将为您详细介绍deque.popleft的相关知识,并且为您解答关于和list.pop的疑问,此外,我们还会提供一些关于Arrays.stream()。map()。sum()的不稳定性能、c – std :: copy和容器的拷贝构造函数之间是否有性能差异?、com.intellij.ui.popup.list.ListPopupImpl的实例源码、DDR4 3200和3600有明显的性能差异吗?的有用信息。
本文目录一览:- deque.popleft()和list.pop(0)。有性能差异吗?(list中pop)
- Arrays.stream()。map()。sum()的不稳定性能
- c – std :: copy和容器的拷贝构造函数之间是否有性能差异?
- com.intellij.ui.popup.list.ListPopupImpl的实例源码
- DDR4 3200和3600有明显的性能差异吗?
deque.popleft()和list.pop(0)。有性能差异吗?(list中pop)
deque.popleft()
并且list.pop(0)
似乎返回相同的结果。它们之间有什么性能差异,为什么?
答案1
小编典典deque.popleft()比list.pop(0)更快,这是因为deque已被优化以在O(1)中执行popleft(),而list.pop(0)需要O(n)(请参阅deque对象) 。
_collectionsmodule.c中用于deque的注释和代码以及listobject.c中用于list的注释和代码提供了实现见解,以解释性能差异。即,双端队列对象“由双向链接列表组成”,可以有效地优化两端的追加和弹出,而列表对象甚至不是单链接列表,而是C数组(指向元素的指针)(请参阅Python
2.7 listobject。
h#l22和Python
3.5
listobject.h#l23),这使其非常适合元素的快速随机访问,但在移除第一个元素之后需要O(n)时间来重新放置所有元素。
对于Python 2.7和3.5,这些源代码文件的URL为:
https://hg.python.org/cpython/file/2.7/Modules/_collectionsmodule.c
https://hg.python.org/cpython/file/2.7/Objects/listobject.c
https://hg.python.org/cpython/file/3.5/Modules/_collectionsmodule.c
https://hg.python.org/cpython/file/3.5/Objects/listobject.c
使用%timeit,当双端队列和列表具有相同的52个元素时,deque.popleft()和list.pop(0)之间的性能差异约为4倍,而当长度为10
** 8。测试结果如下。
import stringfrom collections import deque%timeit d = deque(string.letters); d.popleft()1000000 loops, best of 3: 1.46 µs per loop%timeit d = deque(string.letters)1000000 loops, best of 3: 1.4 µs per loop%timeit l = list(string.letters); l.pop(0)1000000 loops, best of 3: 1.47 µs per loop%timeit l = list(string.letters);1000000 loops, best of 3: 1.22 µs per loopd = deque(range(100000000))%timeit d.popleft()10000000 loops, best of 3: 90.5 ns per loopl = range(100000000)%timeit l.pop(0)10 loops, best of 3: 93.4 ms per loop
Arrays.stream()。map()。sum()的不稳定性能
我遇到了一个非常原始的数组上非常简单的map / reduce操作的性能配置文件实例。这是我的jmh基准代码:
@OutputTimeUnit(TimeUnit.NANOSECONDS)@BenchmarkMode(Mode.AverageTime)@OperationsPerInvocation(Measure.ARRAY_SIZE)@Warmup(iterations = 300, time = 200, timeUnit=MILLISECONDS)@Measurement(iterations = 1, time = 1000, timeUnit=MILLISECONDS)@State(Scope.Thread)@Threads(1)@Fork(1)public class Measure{ static final int ARRAY_SIZE = 1<<20; final int[] ds = new int[ARRAY_SIZE]; private IntUnaryOperator mapper; @Setup public void setup() { setAll(ds, i->(int)(Math.random()*(1<<7))); final int multiplier = (int)(Math.random()*10); mapper = d -> multiplier*d; } @Benchmark public double multiply() { return Arrays.stream(ds).map(mapper).sum(); }}
以下是典型输出的摘要:
# VM invoker: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/bin/java# VM options: <none># Warmup: 300 iterations, 200 ms each# Measurement: 1 iterations, 1000 ms each# Threads: 1 thread, will synchronize iterations# Benchmark mode: Average time, time/op# Benchmark: org.sample.Measure.multiply# Run progress: 0,00% complete, ETA 00:01:01# Fork: 1 of 1# Warmup Iteration 1: 0,779 ns/op# Warmup Iteration 2: 0,684 ns/op# Warmup Iteration 3: 0,608 ns/op# Warmup Iteration 4: 0,619 ns/op# Warmup Iteration 5: 0,642 ns/op# Warmup Iteration 6: 0,638 ns/op# Warmup Iteration 7: 0,660 ns/op# Warmup Iteration 8: 0,611 ns/op# Warmup Iteration 9: 0,636 ns/op# Warmup Iteration 10: 0,692 ns/op# Warmup Iteration 11: 0,632 ns/op# Warmup Iteration 12: 0,612 ns/op# Warmup Iteration 13: 1,280 ns/op# Warmup Iteration 14: 7,261 ns/op# Warmup Iteration 15: 7,379 ns/op# Warmup Iteration 16: 7,376 ns/op# Warmup Iteration 17: 7,379 ns/op# Warmup Iteration 18: 7,195 ns/op# Warmup Iteration 19: 7,351 ns/op# Warmup Iteration 20: 7,761 ns/op............# Warmup Iteration 100: 7,300 ns/op# Warmup Iteration 101: 7,384 ns/op# Warmup Iteration 102: 7,132 ns/op# Warmup Iteration 103: 7,278 ns/op# Warmup Iteration 104: 7,331 ns/op# Warmup Iteration 105: 7,335 ns/op# Warmup Iteration 106: 7,450 ns/op# Warmup Iteration 107: 7,346 ns/op# Warmup Iteration 108: 7,826 ns/op# Warmup Iteration 109: 7,221 ns/op# Warmup Iteration 110: 8,017 ns/op# Warmup Iteration 111: 7,611 ns/op# Warmup Iteration 112: 7,376 ns/op# Warmup Iteration 113: 0,707 ns/op# Warmup Iteration 114: 0,828 ns/op# Warmup Iteration 115: 0,608 ns/op# Warmup Iteration 116: 0,634 ns/op# Warmup Iteration 117: 0,633 ns/op# Warmup Iteration 118: 0,660 ns/op# Warmup Iteration 119: 0,635 ns/op# Warmup Iteration 120: 0,566 ns/op
关键时刻发生在迭代13和113:首先将性能降低十倍,然后将其恢复。相应的时间是测试运行的2.5和22.5秒。这些事件的时间对阵列大小BTW非常敏感。
有什么可能解释这种行为?JIT编译器可能已经在第一次迭代中完成了工作。没有要说的GC操作(由VisualVM确认)…对于任何种类的解释,我都完全不知所措。
我的Java版本(OS X):
$ java -versionjava version "1.8.0_20"Java(TM) SE Runtime Environment (build 1.8.0_20-b26)Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)
答案1
小编典典JIT将首先编译热循环,该热循环将迭代并操作(映射/减少)数组元素。由于数组包含2个20个元素,因此发生的时间很早。
稍后,JIT编译管道,最有可能在已编译的基准测试方法中内联,并且由于内联限制而无法将其全部编译为一种方法。恰好发生在热循环中达到那些内联限制的情况,并且没有内联对map或sum的调用,因此热循环被无意间“取消了优化”。
-XX:+UnlockDiagnosticVMOptions -XX:+PrintCompilation-XX:+PrintInlining
运行基准测试时使用这些选项,尽早看到以下输出:
1202 487 % 4 java.util.Spliterators$IntArraySpliterator::forEachRemaining @ 49 (68 bytes) @ 53 java.util.stream.IntPipeline$3$1::accept (23 bytes) inline (hot) \-> TypeProfile (1186714/1186714 counts) = java/util/stream/IntPipeline$3$1 @ 12 test.Measure$$Lambda$2/1745776415::applyAsInt (9 bytes) inline (hot) \-> TypeProfile (1048107/1048107 counts) = test/Measure$$Lambda$2 @ 5 test.Measure::lambda$setup$1 (4 bytes) inline (hot) @ 17 java.util.stream.ReduceOps$5ReducingSink::accept (19 bytes) inline (hot) \-> TypeProfile (1048107/1048107 counts) = java/util/stream/ReduceOps$5ReducingSink @ 10 java.util.stream.IntPipeline$$Lambda$3/1779653790::applyAsInt (6 bytes) inline (hot) \-> TypeProfile (1048064/1048064 counts) = java/util/stream/IntPipeline$$Lambda$3 @ 2 java.lang.Integer::sum (4 bytes) inline (hot)
那就是编译的热循环。(这%
意味着已替换堆栈或OSR)
稍后再进行流管道的编译(我怀疑基准方法有10,000次迭代,但我尚未验证):
@ 16 java.util.stream.IntPipeline::sum (11 bytes) inline (hot) \-> TypeProfile (5120/5120 counts) = java/util/stream/IntPipeline$3 @ 2 java.lang.invoke.LambdaForm$MH/1279902262::linkToTargetMethod (8 bytes) force inline by annotation @ 4 java.lang.invoke.LambdaForm$MH/1847865997::identity (18 bytes) force inline by annotation @ 14 java.lang.invoke.LambdaForm$DMH/2024969684::invokeStatic_L_L (14 bytes) force inline by annotation @ 1 java.lang.invoke.DirectMethodHandle::internalMemberName (8 bytes) force inline by annotation @ 10 sun.invoke.util.ValueConversions::identity (2 bytes) inline (hot) @ 7 java.util.stream.IntPipeline::reduce (16 bytes) inline (hot) @ 3 java.util.stream.ReduceOps::makeInt (18 bytes) inline (hot) @ 1 java.util.Objects::requireNonNull (14 bytes) inline (hot) @ 14 java.util.stream.ReduceOps$5::<init> (16 bytes) inline (hot) @ 12 java.util.stream.ReduceOps$ReduceOp::<init> (10 bytes) inline (hot) @ 1 java.lang.Object::<init> (1 bytes) inline (hot) @ 6 java.util.stream.AbstractPipeline::evaluate (94 bytes) inline (hot) @ 50 java.util.stream.AbstractPipeline::isParallel (8 bytes) inline (hot) @ 80 java.util.stream.TerminalOp::getOpFlags (2 bytes) inline (hot) \-> TypeProfile (5122/5122 counts) = java/util/stream/ReduceOps$5 @ 85 java.util.stream.AbstractPipeline::sourceSpliterator (163 bytes) inline (hot) @ 79 java.util.stream.AbstractPipeline::isParallel (8 bytes) inline (hot) @ 88 java.util.stream.ReduceOps$ReduceOp::evaluateSequential (18 bytes) inline (hot) @ 2 java.util.stream.ReduceOps$5::makeSink (5 bytes) inline (hot) @ 1 java.util.stream.ReduceOps$5::makeSink (16 bytes) inline (hot) @ 12 java.util.stream.ReduceOps$5ReducingSink::<init> (15 bytes) inline (hot) @ 11 java.lang.Object::<init> (1 bytes) inline (hot) @ 6 java.util.stream.AbstractPipeline::wrapAndCopyInto (18 bytes) inline (hot) @ 3 java.util.Objects::requireNonNull (14 bytes) inline (hot) @ 9 java.util.stream.AbstractPipeline::wrapSink (37 bytes) inline (hot) @ 1 java.util.Objects::requireNonNull (14 bytes) inline (hot) @ 23 java.util.stream.IntPipeline$3::opWrapSink (10 bytes) inline (hot) \-> TypeProfile (4868/4868 counts) = java/util/stream/IntPipeline$3 @ 6 java.util.stream.IntPipeline$3$1::<init> (11 bytes) inline (hot) @ 7 java.util.stream.Sink$ChainedInt::<init> (16 bytes) inline (hot) @ 1 java.lang.Object::<init> (1 bytes) inline (hot) @ 6 java.util.Objects::requireNonNull (14 bytes) inline (hot) @ 13 java.util.stream.AbstractPipeline::copyInto (53 bytes) inline (hot) @ 1 java.util.Objects::requireNonNull (14 bytes) inline (hot) @ 9 java.util.stream.AbstractPipeline::getStreamAndOpFlags (5 bytes) accessor @ 12 java.util.stream.StreamOpFlag::isKnown (19 bytes) inline (hot) @ 20 java.util.Spliterator::getExactSizeIfKnown (25 bytes) inline (hot) \-> TypeProfile (4870/4870 counts) = java/util/Spliterators$IntArraySpliterator @ 1 java.util.Spliterators$IntArraySpliterator::characteristics (5 bytes) accessor @ 19 java.util.Spliterators$IntArraySpliterator::estimateSize (11 bytes) inline (hot) @ 25 java.util.stream.Sink$ChainedInt::begin (11 bytes) inline (hot) \-> TypeProfile (4870/4870 counts) = java/util/stream/IntPipeline$3$1 @ 5 java.util.stream.ReduceOps$5ReducingSink::begin (9 bytes) inline (hot) \-> TypeProfile (4871/4871 counts) = java/util/stream/ReduceOps$5ReducingSink @ 32 java.util.Spliterator$OfInt::forEachRemaining (53 bytes) inline (hot) @ 12 java.util.Spliterators$IntArraySpliterator::forEachRemaining (68 bytes) inline (hot) @ 53 java.util.stream.IntPipeline$3$1::accept (23 bytes) inline (hot) @ 12 test.Measure$$Lambda$2/1745776415::applyAsInt (9 bytes) inline (hot) \-> TypeProfile (1048107/1048107 counts) = test/Measure$$Lambda$2 @ 5 test.Measure::lambda$setup$1 (4 bytes) inlining too deep @ 17 java.util.stream.ReduceOps$5ReducingSink::accept (19 bytes) inline (hot) \-> TypeProfile (1048107/1048107 counts) = java/util/stream/ReduceOps$5ReducingSink @ 10 java.util.stream.IntPipeline$$Lambda$3/1779653790::applyAsInt (6 bytes) inlining too deep \-> TypeProfile (1048064/1048064 counts) = java/util/stream/IntPipeline$$Lambda$3 @ 53 java.util.stream.IntPipeline$3$1::accept (23 bytes) inline (hot) @ 12 test.Measure$$Lambda$2/1745776415::applyAsInt (9 bytes) inline (hot) \-> TypeProfile (1048107/1048107 counts) = test/Measure$$Lambda$2 @ 5 test.Measure::lambda$setup$1 (4 bytes) inlining too deep @ 17 java.util.stream.ReduceOps$5ReducingSink::accept (19 bytes) inline (hot) \-> TypeProfile (1048107/1048107 counts) = java/util/stream/ReduceOps$5ReducingSink @ 10 java.util.stream.IntPipeline$$Lambda$3/1779653790::applyAsInt (6 bytes) inlining too deep \-> TypeProfile (1048064/1048064 counts) = java/util/stream/IntPipeline$$Lambda$3 @ 38 java.util.stream.Sink$ChainedInt::end (10 bytes) inline (hot) @ 4 java.util.stream.Sink::end (1 bytes) inline (hot) \-> TypeProfile (5120/5120 counts) = java/util/stream/ReduceOps$5ReducingSink @ 12 java.util.stream.ReduceOps$5ReducingSink::get (5 bytes) inline (hot) @ 1 java.util.stream.ReduceOps$5ReducingSink::get (8 bytes) inline (hot) @ 4 java.lang.Integer::valueOf (32 bytes) inline (hot) @ 28 java.lang.Integer::<init> (10 bytes) inline (hot) @ 1 java.lang.Number::<init> (5 bytes) inline (hot) @ 1 java.lang.Object::<init> (1 bytes) inline (hot) @ 12 java.lang.Integer::intValue (5 bytes) accessor
请注意热循环中的方法发生的“内联太深”。
甚至在以后生成的JMH测量循环上进行编译:
26857 685 3 test.generated.Measure_multiply::multiply_avgt_jmhLoop (55 bytes) @ 7 java.lang.System::nanoTime (0 bytes) intrinsic @ 16 test.Measure::multiply (23 bytes) @ 4 java.util.Arrays::stream (8 bytes) @ 4 java.util.Arrays::stream (11 bytes) @ 3 java.util.Arrays::spliterator (10 bytes) @ 6 java.util.Spliterators::spliterator (25 bytes) callee is too large @ 7 java.util.stream.StreamSupport::intStream (14 bytes) @ 6 java.util.stream.StreamOpFlag::fromCharacteristics (37 bytes) callee is too large @ 10 java.util.stream.IntPipeline$Head::<init> (8 bytes) @ 4 java.util.stream.IntPipeline::<init> (8 bytes) @ 4 java.util.stream.AbstractPipeline::<init> (55 bytes) callee is too large @ 11 java.util.stream.IntPipeline::map (26 bytes) @ 1 java.util.Objects::requireNonNull (14 bytes) @ 8 java.lang.NullPointerException::<init> (5 bytes) don''t inline Throwable constructors @ 22 java.util.stream.IntPipeline$3::<init> (20 bytes) @ 16 java.util.stream.IntPipeline$StatelessOp::<init> (29 bytes) callee is too large @ 16 java.util.stream.IntPipeline::sum (11 bytes) @ 2 java.lang.invoke.LambdaForm$MH/1279902262::linkToTargetMethod (8 bytes) force inline by annotation @ 4 java.lang.invoke.LambdaForm$MH/1847865997::identity (18 bytes) force inline by annotation @ 14 java.lang.invoke.LambdaForm$DMH/2024969684::invokeStatic_L_L (14 bytes) force inline by annotation @ 1 java.lang.invoke.DirectMethodHandle::internalMemberName (8 bytes) force inline by annotation @ 10 sun.invoke.util.ValueConversions::identity (2 bytes) @ 7 java.util.stream.IntPipeline::reduce (16 bytes) @ 3 java.util.stream.ReduceOps::makeInt (18 bytes) @ 1 java.util.Objects::requireNonNull (14 bytes) @ 14 java.util.stream.ReduceOps$5::<init> (16 bytes) @ 12 java.util.stream.ReduceOps$ReduceOp::<init> (10 bytes) @ 1 java.lang.Object::<init> (1 bytes) @ 6 java.util.stream.AbstractPipeline::evaluate (94 bytes) callee is too large @ 12 java.lang.Integer::intValue (5 bytes)
请注意,没有尝试内联整个流管道,它在到达热循环之前就已停止运行,请参阅“被调用方太大”,从而重新优化热循环。
例如,可以增加内联限制来避免这种行为-XX:MaxInlineLevel=12
。
c – std :: copy和容器的拷贝构造函数之间是否有性能差异?
解决方法
>如果您正在创建一个副本的新容器,请使用复制构造函数或双迭代器构造函数(如果不同的元素类型).
>如果要替换(分配)现有容器,请使用适当的赋值操作符或赋值成员.
>如果要替换元素的一个子集,请使用std :: copy.
通过准确地表示您想要做什么,您可以向编译器提供最有可能的信息来优化其代码(例如,直接从现有容器中构建可以预先分配正确的内存).
com.intellij.ui.popup.list.ListPopupImpl的实例源码
@Override public void actionPerformed(final AnActionEvent event) { final Project project = event.getProject(); if (project == null) { return; } final ListPopupImpl popup = (ListPopupImpl) JBPopupFactory.getInstance() .createActionGroupPopup(TITLE,new PopupGroup(),event.getDataContext(),JBPopupFactory.ActionSelectionAid.NUMBERING,true,event.getPlace()); JBPopupHelper.disableSpeedSearch(popup); JBPopupHelper.registerShiftActions(popup,TITLE,SHIFT_TITLE); JBPopupHelper.registerCtrlActions(popup,CTRL_TITLE); popup.setAdText(AD_TEXT); popup.showCenteredInCurrentwindow(project); }
private void showHistory() { List<XExpression> expressions = myExpressionEditor.getRecentExpressions(); if (!expressions.isEmpty()) { ListPopupImpl popup = new ListPopupImpl(new BaseListPopupStep<XExpression>(null,expressions) { @Override public PopupStep onChosen(XExpression selectedValue,boolean finalChoice) { myExpressionEditor.setExpression(selectedValue); myExpressionEditor.requestFocusInEditor(); return FINAL_CHOICE; } }) { @Override protected ListCellRenderer getListElementRenderer() { return new ColoredListCellRenderer<XExpression>() { @Override protected void customizeCellRenderer(JList list,XExpression value,int index,boolean selected,boolean hasFocus) { append(value.getExpression()); } }; } }; popup.getList().setFont(EditorUtil.getEditorFont()); popup.showUnderneathOf(myExpressionEditor.getEditorComponent()); } }
private static Action createNumberAction(final int mnemonic,final ListPopupImpl listPopup,final Map<PsiElement,GotoRelatedItem> itemsMap,final Processor<Object> processor) { return new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { for (final Object item : listPopup.getListStep().getValues()) { if (getMnemonic(item,itemsMap) == mnemonic) { listPopup.setFinalRunnable(new Runnable() { @Override public void run() { processor.process(item); } }); listPopup.cloSEOk(null); } } } }; }
private static Action createNumberAction(final int number,final Executor executor) { return new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (listPopup.getSpeedSearch().isHoldingFilter()) return; for (final Object item : listPopup.getListStep().getValues()) { if (item instanceof ItemWrapper && ((ItemWrapper)item).getMnemonic() == number) { listPopup.setFinalRunnable(new Runnable() { @Override public void run() { execute((ItemWrapper)item,executor); } }); listPopup.cloSEOk(null); } } } }; }
private static Action createNumberAction(final int number,executor); } }); listPopup.cloSEOk(null); } } } }; }
private static Action createNumberAction(final int mnemonic,itemsMap) == mnemonic) { listPopup.setFinalRunnable(new Runnable() { @Override public void run() { processor.process(item); } }); listPopup.cloSEOk(null); } } } }; }
private void registeractions(final ListPopupImpl popup) { popup.registeraction("delete",Keystroke.getKeystroke(KeyEvent.VK_DELETE,0),new AbstractAction() { public void actionPerformed(ActionEvent e) { JList list = popup.getList(); int selectedindex = list.getSelectedindex(); ListPopupModel model = (ListPopupModel) list.getModel(); PopupFactoryImpl.ActionItem selectedItem = (PopupFactoryImpl.ActionItem) model.get(selectedindex); if (selectedItem != null && selectedItem.getAction() instanceof RunGoalAction) { RunGoalAction action = (RunGoalAction) selectedItem.getAction(); boolean deleted = ApplicationComponent.getInstance().getState().removeGoal(action.getGoal()); if (deleted) { model.deleteItem(selectedItem); if (selectedindex == list.getModel().getSize()) { // is last list.setSelectedindex(selectedindex - 1); } else { list.setSelectedindex(selectedindex); } } } } }); }
private void showHistory() { List<XExpression> expressions = myExpressionEditor.getRecentExpressions(); if (!expressions.isEmpty()) { ListPopupImpl popup = new ListPopupImpl(new BaseListPopupStep<XExpression>(null,boolean finalChoice) { myExpressionEditor.setExpression(selectedValue); myExpressionEditor.requestFocusInEditor(); return FINAL_CHOICE; } }) { @Override protected ListCellRenderer getListElementRenderer() { return new ColoredListCellRenderer<XExpression>() { @Override protected void customizeCellRenderer(@Nonnull JList list,boolean hasFocus) { append(value.getExpression()); } }; } }; popup.getList().setFont(EditorUtil.getEditorFont()); popup.showUnderneathOf(myExpressionEditor.getEditorComponent()); } }
private static Action createNumberAction(final int number,final Executor executor) { return new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (listPopup.getSpeedSearch().isHoldingFilter()) return; for (final Object item : listPopup.getListStep().getValues()) { if (item instanceof ItemWrapper && ((ItemWrapper)item).getMnemonic() == number) { listPopup.setFinalRunnable(new Runnable() { @Override public void run() { execute((ItemWrapper)item,executor); } }); listPopup.cloSEOk(null); } } } }; }
private static Action createNumberAction(final int mnemonic,itemsMap) == mnemonic) { listPopup.setFinalRunnable(new Runnable() { @Override public void run() { processor.process(item); } }); listPopup.cloSEOk(null); } } } }; }
/** * Override this if you haven't PsiMethod,like in Kotlin. * @param position * @param session * @param fileEditor * @return false to continue for another handler or for default action (step into) */ public boolean doSmartStep(SourcePosition position,final DebuggerSession session,TextEditor fileEditor) { final List<SmartStepTarget> targets = findSmartStepTargets(position); if (!targets.isEmpty()) { final SmartStepTarget firstTarget = targets.get(0); if (targets.size() == 1) { session.sessionResumed(); session.stepInto(true,createMethodFilter(firstTarget)); } else { final Editor editor = fileEditor.getEditor(); final PsiMethodListPopupStep popupStep = new PsiMethodListPopupStep(editor,targets,new PsiMethodListPopupStep.OnChooseRunnable() { public void execute(SmartStepTarget chosenTarget) { session.sessionResumed(); session.stepInto(true,createMethodFilter(chosenTarget)); } }); ListPopupImpl popup = new ListPopupImpl(popupStep); DebuggerUIUtil.registerExtraHandleShortcuts(popup,XDebuggerActions.STEP_INTO); DebuggerUIUtil.registerExtraHandleShortcuts(popup,XDebuggerActions.SMART_STEP_INTO); popup.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { popupStep.getScopeHighlighter().dropHighlight(); if (!e.getValueIsAdjusting()) { final SmartStepTarget selectedTarget = (SmartStepTarget)((JBList)e.getSource()).getSelectedValue(); if (selectedTarget != null) { highlightTarget(popupStep,selectedTarget); } } } }); highlightTarget(popupStep,firstTarget); DebuggerUIUtil.showPopupForEditorLine(popup,editor,position.getLine()); } return true; } return false; }
private void chooseAndQualify(final Editor editor) { final BaseListPopupStep<PsiVariable> step = new BaseListPopupStep<PsiVariable>(QuickFixBundle.message("add.qualifier"),myCandidates) { @Override public PopupStep onChosen(final PsiVariable selectedValue,final boolean finalChoice) { if (selectedValue != null && finalChoice) { WriteCommandAction.runWriteCommandAction(selectedValue.getProject(),new Runnable() { @Override public void run() { qualify(selectedValue,editor); } }); } return FINAL_CHOICE; } @NotNull @Override public String getTextFor(final PsiVariable value) { return value.getName(); } @Override public Icon getIconFor(final PsiVariable aValue) { return aValue.getIcon(0); } }; final ListPopupImpl popup = new ListPopupImpl(step); popup.showInBestPositionFor(editor); }
protected WizardPopup createPopup(WizardPopup parent,PopupStep step,Object parentValue) { if (step instanceof ListPopupStep) { return new ListPopupImpl(parent,(ListPopupStep)step,parentValue); } else if (step instanceof TreePopupStep) { return new TreePopupImpl(parent,(TreePopupStep)step,parentValue); } else { throw new IllegalArgumentException(step.getClass().toString()); } }
@NotNull @Override public ListPopup createConfirmation(String title,final String yesText,String noText,final Runnable onYes,final Runnable onNo,int defaultOptionIndex) { final BaseListPopupStep<String> step = new BaseListPopupStep<String>(title,new String[]{yesText,noText}) { @Override public PopupStep onChosen(String selectedValue,final boolean finalChoice) { if (selectedValue.equals(yesText)) { onYes.run(); } else { onNo.run(); } return FINAL_CHOICE; } @Override public void canceled() { onNo.run(); } @Override public boolean isMnemonicsNavigationEnabled() { return true; } }; step.setDefaultOptionIndex(defaultOptionIndex); final ApplicationEx app = ApplicationManagerEx.getApplicationEx(); return app == null || !app.isUnitTestMode() ? new ListPopupImpl(step) : new MockConfirmation(step,yesText); }
public static void registerExtraHandleShortcuts(final ListPopupImpl popup,String actionName) { AnAction action = ActionManager.getInstance().getAction(actionName); Keystroke stroke = KeymapUtil.getKeystroke(action.getShortcutSet()); if (stroke != null) { popup.registeraction("handleSelection " + stroke,stroke,new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { popup.handleSelect(true); } }); } }
private void showRemoteSelector(@NotNull Component component,@NotNull Point point) { final List<String> remotes = getRemotes(); if (remotes.size() <= 1) { return; } ListPopup popup = new ListPopupImpl(new BaseListPopupStep<String>(null,remotes) { @Override public PopupStep onChosen(String selectedValue,boolean finalChoice) { myRemoteRenderer.updateLinkText(selectedValue); if (myFireOnChangeAction != null && !myTargetEditor.isShowing()) { //fireOnChange only when editing completed myFireOnChangeAction.run(); } return super.onChosen(selectedValue,finalChoice); } }) { @Override public void cancel(InputEvent e) { super.cancel(e); if (myTargetEditor.isShowing()) { //repaint and force move focus to target editor component GitPushTargetPanel.this.repaint(); IdeFocusManager.getInstance(myProject).requestFocus(myTargetEditor,true); } } }; popup.show(new RelativePoint(component,point)); }
protected WizardPopup createPopup(WizardPopup parent,parentValue); } else { throw new IllegalArgumentException(step.getClass().toString()); } }
@NotNull @Override public ListPopup createConfirmation(String title,yesText); }
public ListPopup createConfirmation(String title,int defaultOptionIndex) { final BaseListPopupStep<String> step = new BaseListPopupStep<String>(title,new String[] { yesText,noText }) { @Override public PopupStep onChosen(String selectedValue,final boolean finalChoice) { if (selectedValue.equals(yesText)) { onYes.run(); } else { onNo.run(); } return FINAL_CHOICE; } @Override public void canceled() { } @Override public boolean isMnemonicsNavigationEnabled() { return true; } }; step.setDefaultOptionIndex(defaultOptionIndex); final ApplicationEx app = ApplicationManagerEx.getApplicationEx(); return app == null || !app.isUnitTestMode() ? new ListPopupImpl(step) : new MockConfirmation(step,yesText); }
protected WizardPopup createPopup(WizardPopup parent,Object parentValue) { if (step instanceof AsyncPopupStep) { return new AsyncPopupImpl(parent,(AsyncPopupStep)step,parentValue); } if (step instanceof ListPopupStep) { return new ListPopupImpl(parent,parentValue); } else { throw new IllegalArgumentException(step.getClass().toString()); } }
@Nonnull @Override public ListPopup createConfirmation(String title,yesText,noText) { @Override public PopupStep onChosen(String selectedValue,final boolean finalChoice) { return doFinalStep(selectedValue.equals(yesText) ? onYes : onNo); } @Override public void canceled() { onNo.run(); } @Override public boolean isMnemonicsNavigationEnabled() { return true; } }; step.setDefaultOptionIndex(defaultOptionIndex); final ApplicationEx app = ApplicationManagerEx.getApplicationEx(); return app == null || !app.isUnitTestMode() ? new ListPopupImpl(step) : new MockConfirmation(step,yesText); }
public static void registerExtraHandleShortcuts(final ListPopupImpl popup,String... actionNames) { for (String name : actionNames) { Keystroke stroke = KeymapUtil.getKeystroke(ActionManager.getInstance().getAction(name).getShortcutSet()); if (stroke != null) { popup.registeraction("handleSelection " + stroke,new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { popup.handleSelect(true); } }); } } }
private static Action createNumberAction(final int mnemonic,itemsMap) == mnemonic) { listPopup.setFinalRunnable(() -> processor.process(item)); listPopup.cloSEOk(null); } } } }; }
private void chooseAndQualify(final Editor editor) { final BaseListPopupStep<PsiVariable> step = new BaseListPopupStep<PsiVariable>(JavaQuickFixBundle.message("add.qualifier"),myCandidates) { @Override public PopupStep onChosen(final PsiVariable selectedValue,final boolean finalChoice) { if(selectedValue != null && finalChoice) { WriteCommandAction.runWriteCommandAction(selectedValue.getProject(),new Runnable() { @Override public void run() { qualify(selectedValue,editor); } }); } return FINAL_CHOICE; } @NotNull @Override public String getTextFor(final PsiVariable value) { return value.getName(); } @Override public Icon getIconFor(final PsiVariable aValue) { return IconDescriptorUpdaters.getIcon(aValue,0); } }; final ListPopupImpl popup = new ListPopupImpl(step); popup.showInBestPositionFor(editor); }
private void showHistory() { List<XExpression> expressions = getRecentExpressions(); if(!expressions.isEmpty()) { ListPopupImpl historyPopup = new ListPopupImpl(new BaseListPopupStep<XExpression>(null,expressions) { @Override public PopupStep onChosen(XExpression selectedValue,boolean finalChoice) { setExpression(selectedValue); requestFocusInEditor(); return FINAL_CHOICE; } }) { @Override protected ListCellRenderer getListElementRenderer() { return new ColoredListCellRenderer<XExpression>() { @Override protected void customizeCellRenderer(@NotNull JList list,boolean hasFocus) { append(value.getExpression(),SimpleTextAttributes.REGULAR_ATTRIBUTES); } }; } }; historyPopup.getList().setFont(EditorUtil.getEditorFont()); historyPopup.showUnderneathOf(getEditorComponent()); } }
/** * disables speed search. * * @param popup the popup to disable speed search for */ public static void disableSpeedSearch(final ListPopupImpl popup) { final SpeedSearch speedSearch = popup.getSpeedSearch(); speedSearch.setEnabled(false); speedSearch.addchangelistener(event -> speedSearch.updatePattern("")); }
@NotNull @Override public ListPopup createWizardStep(@NotNull PopupStep step) { return new ListPopupImpl((ListPopupStep)step); }
@NotNull @Override public ListPopup createListPopup(@NotNull ListPopupStep step) { return new ListPopupImpl(step); }
@NotNull @Override public ListPopup createListPopup(@NotNull ListPopupStep step,int maxRowCount) { return new ListPopupImpl(step,maxRowCount); }
private RunListElementRenderer(ListPopupImpl popup,boolean hasSideBar) { super(popup); myPopup1 = popup; myHasSideBar = hasSideBar; }
@NotNull @Override public ListPopup createWizardStep(@NotNull PopupStep step) { return new ListPopupImpl((ListPopupStep) step); }
@NotNull @Override public ListPopup createListPopup(@NotNull ListPopupStep step) { return new ListPopupImpl(step); }
private RunListElementRenderer(ListPopupImpl popup,boolean hasSideBar) { super(popup); myPopup1 = popup; myHasSideBar = hasSideBar; }
@Override protected void showPopup(AnActionEvent e,ListPopup p) { final ListPopupImpl popup = (ListPopupImpl) p; registeractions(popup); super.showPopup(e,popup); }
@Nonnull @Override public ListPopup createWizardStep(@Nonnull PopupStep step) { return new ListPopupImpl((ListPopupStep)step); }
@Nonnull @Override public ListPopup createListPopup(@Nonnull ListPopupStep step) { return new ListPopupImpl(step); }
@Nonnull @Override public ListPopup createListPopup(@Nonnull ListPopupStep step,maxRowCount); }
public MyPopupListElementRenderer(ListPopupImpl aPopup) { super(aPopup); }
@requireddispatchThread @Override public void actionPerformed(@Nonnull AnActionEvent e) { final Project project = getEventProject(e); if (project == null) return; XLocalAttachDebuggerProvider[] providers = Extensions.getExtensions(XLocalAttachDebuggerProvider.EP); new Task.Backgroundable(project,XDebuggerBundle.message("xdebugger.attach.toLocal.action.collectingProcesses"),PerformInBackgroundOption.DEAF) { @Override public void run(@Nonnull ProgressIndicator indicator) { ProcessInfo[] processList = OSProcessUtil.getProcessList(); List<AttachItem> items = collectAttachItems(project,processList,indicator,providers); ApplicationManager.getApplication().invokelater(() -> { if (project.isdisposed()) { return; } ProcessListStep step = new ProcessListStep(items,project); final ListPopup popup = JBPopupFactory.getInstance().createListPopup(step); final JList mainList = ((ListPopupImpl) popup).getList(); ListSelectionListener listener = event -> { if (event.getValueIsAdjusting()) return; Object item = ((JList) event.getSource()).getSelectedValue(); // if a sub-list is closed,fallback to the selected value from the main list if (item == null) { item = mainList.getSelectedValue(); } if (item instanceof AttachItem) { String debuggerName = ((AttachItem)item).getSelectedDebugger().getDebuggerdisplayName(); debuggerName = StringUtil.shortenTextWithEllipsis(debuggerName,50,0); ((ListPopupImpl)popup).setCaption(XDebuggerBundle.message("xdebugger.attach.toLocal.popup.title",debuggerName)); } }; popup.addListSelectionListener(listener); // force first valueChanged event listener.valueChanged(new ListSelectionEvent(mainList,mainList.getMinSelectionIndex(),mainList.getMaxSelectionIndex(),false)); popup.showCenteredInCurrentwindow(project); }); } }.queue(); }
private RunListElementRenderer(ListPopupImpl popup,boolean hasSideBar) { super(popup); myPopup1 = popup; myHasSideBar = hasSideBar; }
DDR4 3200和3600有明显的性能差异吗?
ddr4内存拥有3200和3600型号,对于一般的新手用户来说,肯定不知道两者有没有差距,其实两者拥有差距,但是并不很大,实际使用的时候几乎是感觉不到的。
ddr4 200和3600差别大吗:
答:差距不大。
从实际的体验来看,3200相比3600相差5%左右,在日常使用的时候基本上看不出差别。
当然,在显示器等一系列的硬件条件允许下,内存频率肯定是越高约好的,而且3600可以超越4000频率。
ddr4 3200和3600相关介绍:
1、ddr4内存这里的3200和3600一般指代这款内存的基础频率,为3200MHz/3600MHz。
2、理论上来说,基础频率数值越高,内存的性能也就越优秀,带来的读写速度也就越快。
3、但是光从数值上看其实他们也就差了400MHz,不过10%左右,而实际体验来说差距就更低了。
4、因此,如果我们追求高性能肯定选3600的版本,预算有限的话3200的版本也是完全没问题的。
ddr4 3200和3600注意事项:
1、在两个内存条价格相差很大的情况下,可以用3200,其他的钱可以投入别的硬件。
2、这样操作可以让你的电脑性能更强,毕竟电脑不是只靠一个内存条的。
3、而在购买一个内存条的时候,不仅要通过频率参考性能,还要去看更多的方面。
以上就是DDR4 3200和3600有明显的性能差异吗?的详细内容,更多请关注php中文网其它相关文章!
我们今天的关于deque.popleft和和list.pop的分享已经告一段落,感谢您的关注,如果您想了解更多关于Arrays.stream()。map()。sum()的不稳定性能、c – std :: copy和容器的拷贝构造函数之间是否有性能差异?、com.intellij.ui.popup.list.ListPopupImpl的实例源码、DDR4 3200和3600有明显的性能差异吗?的相关信息,请在本站查询。
本文标签: