Savarese Software Research Corporation
print_memusage.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2009 Savarese Software Research Corporation
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     https://www.savarese.com/software/ApacheLicense-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00023 #ifndef __SSRC_WSPR_UTILITY_PRINT_MEMUSAGE_H
00024 #define __SSRC_WSPR_UTILITY_PRINT_MEMUSAGE_H
00025 
00026 #include <ssrc/wispers/utility/memusage.h>
00027 
00028 #include <ssrc/wispers/utility/BindProperties.h>
00029 #include <ssrc/wispers/utility/PropertiesToString.h>
00030 #include <iostream>
00031 #include <unistd.h>
00032 
00033 __BEGIN_NS_SSRC_WSPR_UTILITY
00034 
00035 #if defined(WISPERS_HAVE_GET_MEMUSAGE)
00036 
00037 inline std::ostream & operator<<(std::ostream & out, const memusage & usage) {
00038   Properties p;
00039   usage.visit(BindProperties(p));
00040   return out << p;
00041 }
00042 
00043 inline void print_memusage(std::ostream & out = std::cerr) {
00044   memusage usage;
00045   get_memusage(::getpid(), usage);
00046   out << usage << std::endl;
00047 }
00048 
00049 #endif
00050 
00051 __END_NS_SSRC_WSPR_UTILITY
00052 
00053 #endif

Savarese Software Research Corporation
Copyright © 2006-2011 Savarese Software Research Corporation. All rights reserved.