Various cleanup

Add script that counts the number of includes
This commit is contained in:
Alexander Bock
2017-03-02 19:50:05 -05:00
parent 1689dc4047
commit fb67e805ac
8 changed files with 112 additions and 58 deletions

View File

@@ -314,10 +314,10 @@ public:
* Property::ViewOptions::PowerScaledCoordinate = <code>powerScaledCoordinate</code>.
*/
struct ViewOptions {
static const std::string Color;
static const std::string LightPosition;
static const std::string PowerScaledScalar;
static const std::string PowerScaledCoordinate;
static const char* Color;
static const char* LightPosition;
static const char* PowerScaledScalar;
static const char* PowerScaledCoordinate;
};
/**
@@ -329,10 +329,10 @@ public:
const ghoul::Dictionary& metaData() const;
protected:
static const std::string IdentifierKey;
static const std::string NameKey;
static const std::string TypeKey;
static const std::string MetaDataKey;
static const char* IdentifierKey;
static const char* NameKey;
static const char* TypeKey;
static const char* MetaDataKey;
/**
* Creates the information that is general to every Property and adds the

View File

@@ -25,7 +25,6 @@
#ifndef __OPENSPACE_CORE___PROPERTYOWNER___H__
#define __OPENSPACE_CORE___PROPERTYOWNER___H__
#include <openspace/properties/property.h>
#include <map>
#include <string>
#include <vector>
@@ -33,6 +32,8 @@
namespace openspace {
namespace properties {
class Property;
/**
* A PropertyOwner can own Propertys or other PropertyOwner and provide access to both in
* a unified way. The <code>identifier</code>s and <code>name</code>s of Propertys and

View File

@@ -43,14 +43,14 @@
namespace ghoul {
namespace filesystem {
class File;
}
namespace opengl {
class ProgramObject;
class Texture;
}
}
namespace filesystem { class File; }
namespace opengl {
class ProgramObject;
class Texture;
} // namepsace opengl
} // namespace ghoul
namespace openspace {

View File

@@ -27,6 +27,10 @@
#include <openspace/properties/propertyowner.h>
#include <memory>
namespace ghoul { class Dictionary; }
namespace openspace {
class Renderable;

View File

@@ -27,7 +27,6 @@
#include <openspace/openspace.h>
#include <openspace/documentation/core_registration.h>
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/documentationengine.h>
#include <openspace/engine/configurationmanager.h>
#include <openspace/engine/downloadmanager.h>
@@ -38,13 +37,8 @@
#include <openspace/engine/wrapper/windowwrapper.h>
#include <openspace/interaction/interactionhandler.h>
#include <openspace/interaction/luaconsole.h>
#include <openspace/mission/missionmanager.h>
#include <openspace/network/networkengine.h>
#include <openspace/properties/propertyowner.h>
#include <openspace/rendering/renderable.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/rendering/screenspacerenderable.h>
#include <openspace/scripting/scriptengine.h>
#include <openspace/scripting/scriptscheduler.h>
#include <openspace/scene/rotation.h>
#include <openspace/scene/scale.h>
@@ -55,28 +49,18 @@
#include <openspace/util/time.h>
#include <openspace/util/timemanager.h>
#include <openspace/util/spicemanager.h>
#include <openspace/util/syncbuffer.h>
#include <openspace/util/transformationmanager.h>
#include <ghoul/ghoul.h>
#include <ghoul/cmdparser/commandlineparser.h>
#include <ghoul/cmdparser/singlecommand.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/filesystem/cachemanager.h>
#include <ghoul/font/fontmanager.h>
#include <ghoul/font/fontrenderer.h>
#include <ghoul/logging/consolelog.h>
#include <ghoul/logging/visualstudiooutputlog.h>
#include <ghoul/lua/ghoul_lua.h>
#include <ghoul/lua/lua_helper.h>
#include <ghoul/lua/luastate.h>
#include <ghoul/misc/dictionary.h>
#include <ghoul/misc/exception.h>
#include <ghoul/misc/onscopeexit.h>
#include <ghoul/systemcapabilities/systemcapabilities>
#include <fstream>
#include <queue>
#if defined(_MSC_VER) && defined(OPENSPACE_ENABLE_VLD)
#include <vld.h>

View File

@@ -32,24 +32,24 @@ namespace openspace {
namespace properties {
namespace {
const std::string _loggerCat = "Property";
const std::string MetaDataKeyGuiName = "guiName";
const std::string MetaDataKeyGroup = "Group";
const std::string MetaDataKeyVisibility = "Visibility";
const std::string MetaDataKeyReadOnly = "isReadOnly";
const char* _loggerCat = "Property";
const char* MetaDataKeyGuiName = "guiName";
const char* MetaDataKeyGroup = "Group";
const char* MetaDataKeyVisibility = "Visibility";
const char* MetaDataKeyReadOnly = "isReadOnly";
const std::string _metaDataKeyViewPrefix = "view.";
const char* _metaDataKeyViewPrefix = "view.";
}
const std::string Property::ViewOptions::Color = "color";
const std::string Property::ViewOptions::LightPosition = "lightPosition";
const std::string Property::ViewOptions::PowerScaledCoordinate = "powerScaledCoordinate";
const std::string Property::ViewOptions::PowerScaledScalar = "powerScaledScalar";
const char* Property::ViewOptions::Color = "color";
const char* Property::ViewOptions::LightPosition = "lightPosition";
const char* Property::ViewOptions::PowerScaledCoordinate = "powerScaledCoordinate";
const char* Property::ViewOptions::PowerScaledScalar = "powerScaledScalar";
const std::string Property::IdentifierKey = "Identifier";
const std::string Property::NameKey = "Name";
const std::string Property::TypeKey = "Type";
const std::string Property::MetaDataKey = "MetaData";
const char* Property::IdentifierKey = "Identifier";
const char* Property::NameKey = "Name";
const char* Property::TypeKey = "Type";
const char* Property::MetaDataKey = "MetaData";
Property::Property(std::string identifier, std::string guiName, Visibility visibility)
: _owner(nullptr)
@@ -181,7 +181,7 @@ void Property::notifyListener() {
std::string Property::generateBaseDescription() const {
return
TypeKey + " = \"" + className() + "\", " +
std::string(TypeKey) + " = \"" + className() + "\", " +
IdentifierKey + " = \"" + fullyQualifiedIdentifier() + "\", " +
NameKey + " = \"" + guiName() + "\", " +
generateMetaDataDescription() + ", " +
@@ -201,7 +201,7 @@ std::string Property::generateMetaDataDescription() const {
std::string vis = VisibilityConverter.at(visibility);
return
MetaDataKey + " = {" +
std::string(MetaDataKey) + " = {" +
MetaDataKeyGroup + " = '" + groupIdentifier() + "'," +
MetaDataKeyVisibility + " = " + vis + "," +
MetaDataKeyReadOnly +" = " + (isReadOnly ? "true" : "false") + "}";

View File

@@ -24,6 +24,7 @@
#include <openspace/properties/propertyowner.h>
#include <openspace/properties/property.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/misc/assert.h>
@@ -33,17 +34,16 @@ namespace openspace {
namespace properties {
namespace {
const char* _loggerCat = "PropertyOwner";
const char* _loggerCat = "PropertyOwner";
bool propertyLess(Property* lhs, Property* rhs)
{
return lhs->identifier() < rhs->identifier();
}
bool propertyLess(Property* lhs, Property* rhs)
{
return lhs->identifier() < rhs->identifier();
}
bool subOwnerLess(PropertyOwner* lhs, PropertyOwner* rhs) {
return lhs->name() < rhs->name();
}
bool subOwnerLess(PropertyOwner* lhs, PropertyOwner* rhs) {
return lhs->name() < rhs->name();
}
} // namespace

View File

@@ -0,0 +1,65 @@
"""
OpenSpace
Copyright (c) 2014-2017
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be included in all copies
or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This file takes the output of compiling in Visual Studio with /showIncludes enabled and
counts the number of times that each header file is included (excluding system headers).
This gives an indicator as to which header files can be made more efficient the most
efficiently
The script requires one argument, which is the text file of one or many runs of the
Visual Studio compiler
"""
import sys
if len(sys.argv) != 2:
print("Usage: count_includes.py <text file containing /showIncludes results")
exit(0)
file = sys.argv[1]
with open(file) as f:
lines = f.readlines()
# Only get the lines that actually have includes
lines = [l for l in lines if "Note: including file" in l]
# Prefix to remove from each line an
prefix = "X> Note: including file:"
lines = [l[len(prefix):-1].strip() for l in lines]
# Remove system header
lines = [l for l in lines if "windows kits" not in l.lower()]
lines = [l for l in lines if "microsoft visual studio " not in l.lower()]
# Remove external headers
lines = [l for l in lines if "ghoul\\ext\\" not in l.lower()]
count = {}
for l in lines:
if l in count:
count[l] = count[l] + 1
else:
count[l] = 1
for key, value in sorted(count.iteritems(), key=lambda (k,v): (v,k)):
print("%s: %s" % (key.ljust(100), value))