/****** uti/monitor/sge_monitor_output() *************************************** * NAME * sge_monitor_output() -- outputs the result into the message file * * SYNOPSIS * void sge_monitor_output(monitoring_t *monitor) * * FUNCTION * This function computes the output line from the gathered statistics. * The output is only generated, when the the output flag in the * monitoring structure is set. * * The monitoring line is printed to the message file in the profiling * class and it made available for the qping -f output. For the qping * output, it stores the the generation time, though that qping can * show, when the message was generated. * * If an extension is set, it calls the apropriate output function for * it. * * INPUTS * monitoring_t *monitor - the monitoring info * * NOTES * MT-NOTE: sge_monitor_output() is MT safe * *******************************************************************************/ void sge_monitor_output(monitoring_t *monitor) { DENTER(GDI_LAYER, "sge_monitor_output"); if ((monitor != NULL) && (monitor->output == true)) { struct timeval after; double time; gettimeofday(&after, NULL); time = after.tv_usec - monitor->now.tv_usec; time = after.tv_sec - monitor->now.tv_sec + (time/1000000); sge_dstring_clear(monitor->work_line); sge_dstring_sprintf_append(monitor->work_line, MSG_UTI_MONITOR_DEFLINE_SF, monitor->thread_name, monitor->message_in_count/time); if (monitor->ext_type != NONE_EXT) { sge_dstring_append(monitor->work_line, " ("); monitor->ext_output(monitor->work_line, monitor->ext_data, time); sge_dstring_append(monitor->work_line, ")"); }; sge_dstring_sprintf_append(monitor->work_line, MSG_UTI_MONITOR_DEFLINE_FFFFF, monitor->message_out_count/time, monitor->message_in_count ? (time - monitor->idle)/monitor->message_in_count: 0, monitor->idle/time*100, monitor->wait/time*100, time); /* only log into the message file, if the user wants it */ if (monitor->log_monitor_mes) { sge_log(LOG_PROF, sge_dstring_get_string(monitor->work_line),__FILE__,SGE_FUNC,__LINE__); } if (monitor->pos != -1) { dstring *tmp = NULL; sge_mutex_lock("sge_monitor_init", SGE_FUNC, __LINE__, &(Output[monitor->pos].Output_Mutex)); tmp = Output[monitor->pos].output; Output[monitor->pos].output = monitor->work_line; Output[monitor->pos].update_time = after.tv_sec; sge_mutex_unlock("sge_monitor_init", SGE_FUNC, __LINE__, &(Output[monitor->pos].Output_Mutex)); monitor->work_line = tmp; } sge_monitor_reset(monitor); } DRETURN_VOID; }
int main( int _argc, char *_argv[]) try { fcppt::log::activate_levels( sge::log::global(), fcppt::log::level::debug); sgetris::program_options().add_options() ( "help", "produce help message") ( "screen-size", boost::program_options::value<sge::renderer::screen_size>()->default_value( sge::renderer::screen_size( 1024, 768)), "Change screen resolution (format: (w,h))") ( "fps", boost::program_options::value<bool>()->default_value( true), "Show frames per second"); sgetris::log_switcher sge_log( &sgetris::program_options, FCPPT_TEXT("sge"), sge::log::global_context()), sgetris_log( &sgetris::program_options, FCPPT_TEXT("sgetris"), sgetris::log::context()); boost::program_options::variables_map vm; boost::program_options::store( boost::program_options::parse_command_line( _argc, _argv, sgetris::program_options()), vm); boost::program_options::notify( vm); sge_log.apply( vm); sgetris_log.apply( vm); if (vm.count("help")) { std::cout << sgetris::program_options() << "\n"; return 0; } sge::renderer::screen_size const screens = vm["screen-size"].as<sge::renderer::screen_size>(); sge::systems::instance sys( sge::systems::list() ( sge::window::parameters( FCPPT_TEXT("sgetris snowflaketest") ) ) ( sge::renderer::parameters( sge::renderer::display_mode( screens, sge::renderer::bit_depth::depth32, sge::renderer::refresh_rate_dont_care ), sge::renderer::depth_buffer::off, sge::renderer::stencil_buffer::off, sge::renderer::window_mode::windowed, sge::renderer::vsync::on, sge::renderer::no_multi_sampling ) ) (sge::systems::parameterless::input) (sge::systems::parameterless::audio_player) ( sge::systems::image_loader( sge::image::capabilities_field::null(), fcppt::assign::make_container< sge::extension_set >( FCPPT_TEXT("png") ) ) ) ( sge::systems::audio_loader( sge::audio::loader_capabilities_field::null(), sge::all_extensions ) ) (sge::systems::parameterless::font) ); bool running = true; sgetris::sound_manager sm( sys.audio_loader(), sys.audio_player()); sgetris::texture_manager tm( sys.image_loader(), sys.renderer() ); fcppt::signal::scoped_connection const cb( sys.input_system()->register_callback( sge::input::action( sge::input::kc::key_escape, boost::phoenix::ref(running) = false))); fcppt::scoped_ptr<sgetris::backgrounds::base> bg( new sgetris::backgrounds::flakes::object( vm, sys.renderer(), tm)); sge::font::metrics_ptr const metrics( sys.font_system()->create_font( sge::config::media_path() / FCPPT_TEXT("fonts") / FCPPT_TEXT("default.ttf"), static_cast<sge::font::size_type>( 15))); sge::font::drawer_ptr const drawer( fcppt::make_shared_ptr< sge::font::drawer_3d >( sys.renderer(), sge::image::colors::green())); sge::font::object font( metrics, drawer); sge::time::frames_counter frames_counter; sgetris::machine m( vm, sys, tm); m.initiate(); sge::time::duration t = sge::time::now().time_since_epoch(); while(running) { frames_counter.update(); sge::time::duration const newtime = sge::time::now().time_since_epoch(), diff_duration = newtime - t; t = newtime; sgetris::time_delta const diff( diff_duration.count() ); sge::mainloop::dispatch(); sge::renderer::scoped_block const block_( sys.renderer()); bg->update( diff); m.process_event( sgetris::events::tick( diff)); bg->draw(); if (vm["fps"].as<bool>()) font.draw_text( FCPPT_TEXT("fps: ")+frames_counter.frames_str(), sge::font::pos::null(), fcppt::math::dim::structure_cast<sge::font::dim>( sys.renderer()->screen_size()), sge::font::align_h::left, sge::font::align_v::top); } fcppt::io::cerr << "Am Ende von main\n"; } catch(fcppt::exception const &e) { fcppt::io::cerr << e.string() << FCPPT_TEXT('\n'); return EXIT_FAILURE; } catch(std::exception const &e) { std::cerr << e.what() << FCPPT_TEXT('\n'); return EXIT_FAILURE; } catch (...) { fcppt::io::cerr << FCPPT_TEXT("Caught someting unknown"); }