<commit_before>#!/usr/bin/env python
# Copyright 2009 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Module for all nameserver related activity."""

__author__ = '<EMAIL> (<NAME>)'

import re
import socket
import sys
import time


if __name__ == '__main__':
  sys.path.append('../nb_third_party')

# external dependencies (from nb_third_party)
import dns.exception
import dns.message
import dns.name
import dns.query
import dns.rcode
import dns.rdataclass
import dns.rdatatype
import dns.resolver
import dns.reversename
import dns.version

import health_checks
import util

# Look for buggy system versions of namebench
if dns.version.hexversion < 17301744:
  raise ValueError('dnspython 1.8.0+ required, while only %s was found. The '
                   'namebench source bundles 1.8.0, so use it.' % dns.version.version)



# How many failures before we disable system nameservers
MAX_NORMAL_FAILURES = 2
MAX_SYSTEM_FAILURES = 7
MAX_PREFERRED_FAILURES = 5
MAX_WARNINGS = 7

FAILURE_PRONE_RATE = 10

    
def _DoesClockGoBackwards():
  """Detect buggy Windows systems where time.clock goes backwards"""
  reference = 0
  print "Checking if time goes backwards..."
  for x in range(0, 250):
    counter = time.clock()
    if counter < reference:
      print "Clock went backwards by %fms" % (counter - reference)
      return True
    reference = counter
    time.sleep(random.random() / 100)<commit_msg>Make _DoesClockGoBackwards() run a bit faster<commit_after>#!/usr/bin/env python
# Copyright 2009 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Module for all nameserver related activity."""

__author__ = '<EMAIL> (<NAME>)'

import random
import re
import socket
import sys
import time


if __name__ == '__main__':
  sys.path.append('../nb_third_party')

# external dependencies (from nb_third_party)
import dns.exception
import dns.message
import dns.name
import dns.query
import dns.rcode
import dns.rdataclass
import dns.rdatatype
import dns.resolver
import dns.reversename
import dns.version

import health_checks
import util

# Look for buggy system versions of namebench
if dns.version.hexversion < 17301744:
  raise ValueError('dnspython 1.8.0+ required, while only %s was found. The '
                   'namebench source bundles 1.8.0, so use it.' % dns.version.version)



# How many failures before we disable system nameservers
MAX_NORMAL_FAILURES = 2
MAX_SYSTEM_FAILURES = 7
MAX_PREFERRED_FAILURES = 5
MAX_WARNINGS = 7

FAILURE_PRONE_RATE = 10

    
def _DoesClockGoBackwards():
  """Detect buggy Windows systems where time.clock goes backwards"""
  reference = 0
  print "Checking if time.clock() goes backwards (broken hardware)..."
  for x in range(0, 250):
    counter = time.clock()
    if counter < reference:
      print "Clock went backwards by %fms" % (counter - reference)
      return True
    reference = counter
    time.sleep(random.random() / 500)
{'fraction_non_alphanumeric': 0.08320687910976227, 'fraction_numerical': 0.018209408194233688, 'mean_word_length': 4.0, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1652302', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1146, 'n_words': 456}