github.com/apache/beam/sdks/v2@v2.48.2/python/apache_beam/testing/benchmarks/nexmark/nexmark_perf.py (about)

     1  #
     2  # Licensed to the Apache Software Foundation (ASF) under one or more
     3  # contributor license agreements.  See the NOTICE file distributed with
     4  # this work for additional information regarding copyright ownership.
     5  # The ASF licenses this file to You under the Apache License, Version 2.0
     6  # (the "License"); you may not use this file except in compliance with
     7  # the License.  You may obtain a copy of the License at
     8  #
     9  #    http://www.apache.org/licenses/LICENSE-2.0
    10  #
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  # See the License for the specific language governing permissions and
    15  # limitations under the License.
    16  #
    17  
    18  """
    19  performance summary for a run of nexmark query
    20  """
    21  
    22  
    23  class NexmarkPerf(object):
    24    def __init__(
    25        self,
    26        runtime_sec=None,
    27        event_count=None,
    28        event_per_sec=None,
    29        result_count=None):
    30      # the time difference between first seen input and the last seen result
    31      self.runtime_sec = runtime_sec if runtime_sec else -1.0
    32      # the count of input event seen
    33      self.event_count = event_count if event_count else -1
    34      # number of event processed per runtime_sec
    35      self.event_per_sec = event_per_sec if event_per_sec else -1.0
    36      # number of result produced
    37      self.result_count = result_count if result_count else -1
    38  
    39    def has_progress(self, previous_perf):
    40      # type: (NexmarkPerf) -> bool
    41  
    42      """
    43      Args:
    44        previous_perf: a NexmarkPerf object to be compared to self
    45  
    46      Returns:
    47        True if there are observed pipeline activity between self and other
    48          NexmarkPerf values
    49      """
    50      if (self.runtime_sec != previous_perf.runtime_sec or
    51          self.event_count != previous_perf.event_count or
    52          self.result_count != previous_perf.result_count):
    53        return True
    54      return False