• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

WTF

HashTable.cpp

Go to the documentation of this file.
00001 /*
00002     This file is part of the KDE libraries
00003 
00004     Copyright (C) 2005 Apple Computer
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #include "HashTable.h"
00023 #include <config.h>
00024 
00025 namespace WTF {
00026 
00027 #if DUMP_HASHTABLE_STATS
00028 
00029 int HashTableStats::numAccesses;
00030 int HashTableStats::numCollisions;
00031 int HashTableStats::collisionGraph[4096];
00032 int HashTableStats::maxCollisions;
00033 int HashTableStats::numRehashes;
00034 int HashTableStats::numRemoves;
00035 int HashTableStats::numReinserts;
00036 
00037 static HashTableStats logger;
00038 
00039 HashTableStats::~HashTableStats()
00040 {
00041     printf("\nkhtml::HashTable statistics\n\n");
00042     printf("%d accesses\n", numAccesses);
00043     printf("%d total collisions, average %.2f probes per access\n", numCollisions, 1.0 * (numAccesses + numCollisions) / numAccesses);
00044     printf("longest collision chain: %d\n", maxCollisions);
00045     for (int i = 1; i <= maxCollisions; i++) {
00046         printf("  %d lookups with exactly %d collisions (%.2f%% , %.2f%% with this many or more)\n", collisionGraph[i], i, 100.0 * (collisionGraph[i] - collisionGraph[i+1]) / numAccesses, 100.0 * collisionGraph[i] / numAccesses);
00047     }
00048     printf("%d rehashes\n", numRehashes);
00049     printf("%d reinserts\n", numReinserts);
00050 }
00051 
00052 void HashTableStats::recordCollisionAtCount(int count)
00053 {
00054     if (count > maxCollisions)
00055         maxCollisions = count;
00056     numCollisions++;
00057     collisionGraph[count]++;
00058 }
00059 
00060 #endif
00061 
00062 } // namespace WTF

WTF

Skip menu "WTF"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   WTF
  • KJSEmbed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  •   core
  • Phonon
  •   Backend
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal