1

以下三个边框对象在性能方面有什么区别吗?

<Border Grid.Column="0" Grid.ColumnSpan="2" Opacity="1">
  <Border.Background>
    <DrawingBrush>
      <DrawingBrush.Drawing>
        <DrawingGroup>
          <GeometryDrawing Brush="Red">
            <GeometryDrawing.Geometry>
              <GeometryGroup>
                <RectangleGeometry Rect="0,0 100,1000" />
                <LineGeometry StartPoint="0,0" EndPoint="100,1000"/>
                <LineGeometry StartPoint="100,0" EndPoint="0,1000"/>
              </GeometryGroup>
            </GeometryDrawing.Geometry>
            <GeometryDrawing.Pen>
              <Pen Thickness="20" Brush="Black"/>
            </GeometryDrawing.Pen>
          </GeometryDrawing>
        </DrawingGroup>
      </DrawingBrush.Drawing>
    </DrawingBrush>
  </Border.Background>
</Border>

<Border Grid.Column="0" Grid.ColumnSpan="2" Opacity="1">
  <Border.Background>
    <DrawingBrush>
      <DrawingBrush.Drawing>
        <DrawingGroup>
          <GeometryDrawing Brush="Red">
            <GeometryDrawing.Geometry>
              <RectangleGeometry Rect="0,0 100,1000" />
            </GeometryDrawing.Geometry>
            <GeometryDrawing.Pen>
              <Pen Thickness="20" Brush="Black"/>
            </GeometryDrawing.Pen>
          </GeometryDrawing>
          <GeometryDrawing>
            <GeometryDrawing.Geometry>
              <LineGeometry StartPoint="0,0" EndPoint="100,1000"/>
            </GeometryDrawing.Geometry>
            <GeometryDrawing.Pen>
              <Pen Thickness="20" Brush="Black"/>
            </GeometryDrawing.Pen>
          </GeometryDrawing>
          <GeometryDrawing>
            <GeometryDrawing.Geometry>
              <LineGeometry StartPoint="100,0" EndPoint="0,1000"/>
            </GeometryDrawing.Geometry>
            <GeometryDrawing.Pen>
              <Pen Thickness="20" Brush="Black"/>
            </GeometryDrawing.Pen>
          </GeometryDrawing>
        </DrawingGroup>
      </DrawingBrush.Drawing>
    </DrawingBrush>
  </Border.Background>
</Border>

<Border Grid.Column="3" Grid.ColumnSpan="2" Opacity="1">
  <Image Stretch="Uniform">
    <Image.Source>
      <DrawingImage>
        <DrawingImage.Drawing>
          <DrawingGroup>
            <GeometryDrawing Brush="Red">
              <GeometryDrawing.Geometry>
                <GeometryGroup>
                  <RectangleGeometry Rect="0,0 100,1000" />
                  <LineGeometry StartPoint="0,0" EndPoint="100,1000"/>
                  <LineGeometry StartPoint="100,0" EndPoint="0,1000"/>
                </GeometryGroup>
              </GeometryDrawing.Geometry>
              <GeometryDrawing.Pen>
                <Pen Thickness="20" Brush="Black"/>
              </GeometryDrawing.Pen>
            </GeometryDrawing>
          </DrawingGroup>
        </DrawingImage.Drawing>
      </DrawingImage>
    </Image.Source>
  </Image>
</Border>
4

1 回答 1

4

这是诸如您的问题的标准答案,这些问题归结为“A 比 B 快吗?” ...

尝试两个(或所有三个或多个)并测量执行时间。来自第一原则的论点不会回答这个问题,尽管它们可能会产生大量的热空气。

请不要以为我在用一个油嘴滑舌的答案刷你,我目前在哪里工作,地球物理学的并行计算,性能非常重要。来之不易的经验告诉我,确定 A 是否比 B 快的唯一方法是测量两者。如果不值得同时编码来衡量差异,那么差异并不重要!

于 2009-08-26T23:26:23.773 回答