Esempio n. 1
0
void Interface::showStatisticsDialog()
{
    if ( mStatisticsDialog == 0 )
    {
        mStatisticsDialog = new InterfaceStatisticsDialog( this );
        if ( mIfaceStatistics == 0 )
        {
            // should never happen but you never know...
            startStatistics();
        }
        connect( mStatisticsDialog, SIGNAL( clearStatistics() ), mIfaceStatistics, SLOT( clearStatistics() ) );
    }
    mStatisticsDialog->show();
}
Esempio n. 2
0
int main(int argc, char *argv[])
{
	if ((argc < 6) || (argc > 9))
	{
		usage(argv[0]);
		exit(EXIT_FAILURE);
	}
	//mtarray numThreads threadMemSize rwRatio maxWrapSize numWraps [wrapType [options]
	numThreads = getIntArg(argv[1]);
	threadMemSize = getIntArg(argv[2]);
	rwRatio = getIntArg(argv[3]);
	wrapSize = getIntArg(argv[4]);
	numWraps = getIntArg(argv[5]);
	delay = getIntArg(argv[6]);

	if ((numThreads < 0) || (threadMemSize < 0) || (delay < 0) || (rwRatio < 0) || (wrapSize < 0) || (numWraps < 0))
	{
		usage(argv[0]);
		exit(EXIT_FAILURE);
	}
	int wrapType;
	int wrapOptions;
	if (argc >= 8)
	{
		wrapType = getIntArg(argv[7]);
		if (wrapType < 0)
		{
			usage(argv[0]);
			exit(EXIT_FAILURE);
		}
		if (wrapType == Wrap_Software)
		{
			setAliasTableWorkers(numThreads);
		}
		setWrapImpl((WrapImplType)wrapType);
		if (argc >= 9)
		{
			wrapOptions = getIntArg(argv[8]);
			if (wrapOptions < 0)
			{
				usage(argv[0]);
				exit(EXIT_FAILURE);
			}
			setWrapImplOptions(wrapOptions);
		}
	}

	//  Display memory attributes.
	printMemoryAttributes();

	arraySize = numThreads * threadMemSize;

	StartPhysicalTracer();
	startStatistics();

	//data = (int *)pmalloc(arraySize * sizeof(int));
	//printf("Array size=%d integers with start address: %p\n", arraySize, data);

	//  Create the test threads
	pthread_t *testers = (pthread_t *)malloc(numThreads * sizeof(pthread_t));
	for (int i = 0; i < numThreads; i++)
	{
		pthread_create(&testers[i], NULL, test, (void*)(int64_t)i);
	}

	printf("joining\n");
	for (int i = 0; i < numThreads; i++)
	{
		pthread_join(testers[i], NULL);
	}
	free(testers);

	EndPhysicalTracer();

	printf("%s \t%s \t%s \t%s \t", argv[0], argv[1], argv[2], argv[3]);
	printStatistics(stdout);

	wrapCleanup();

	return 0;
}
Esempio n. 3
0
int main(int argc, char *argv[])
{
	if ((argc < 4) || (argc > 6))
	{
		usage(argv[0]);
		exit(EXIT_FAILURE);
	}

	int arrayTraceOption = getIntArg(argv[1]);
	int wrapSize = getIntArg(argv[2]);
	int numWraps = getIntArg(argv[3]);

	if ((arrayTraceOption < 0) || (wrapSize < 0) || (numWraps < 0))
	{
		usage(argv[0]);
		exit(EXIT_FAILURE);
	}
	int wrapType;
	int wrapOptions;
	if (argc >= 5)
	{
		wrapType = getIntArg(argv[4]);
		if (wrapType < 0)
		{
			usage(argv[0]);
			exit(EXIT_FAILURE);
		}
		setWrapImpl((WrapImplType)wrapType);
		if (argc >= 6)
		{
			wrapOptions = getIntArg(argv[5]);
			if (wrapOptions < 0)
			{
				usage(argv[0]);
				exit(EXIT_FAILURE);
			}
			setWrapImplOptions(wrapOptions);
		}
	}

	//  Display memory attributes.
	printMemoryAttributes();

	if (arrayTraceOption == 0)
		arraySize = numWraps * wrapSize * IntsPerLine;
	else if (arrayTraceOption == 1)
		arraySize = numWraps * wrapSize;
	else if (arrayTraceOption == 2)
		arraySize = wrapSize*numWraps;
		//arraySize = dmax(BlockSize, wrapSize * numWraps);
	else if (arrayTraceOption == 3)
		arraySize = BlockSize /sizeof(int) * numWraps;
	else if (arrayTraceOption == 4)
		arraySize = (BlockSize / sizeof(int))*numWraps;
	else
		assert(0);

	StartPhysicalTracer();
	startStatistics();

	arraySize = 20000;

	int *data = (int *)pmalloc(arraySize * sizeof(int));
	printf("Array size=%d integers with start address: %p\n", arraySize, data);

	//init(data, arraysize, hotCache);

	if (arrayTraceOption == 4)
		blockCow(data, numWraps, wrapSize, arraySize);
	else
		trace(data, numWraps, wrapSize, IntsPerLine, arrayTraceOption);

	EndPhysicalTracer();

	printf("%s \t%s \t%s \t%s \t", argv[0], argv[1], argv[2], argv[3]);
	printStatistics(stdout);

	wrapCleanup();
	pfree(data);
	//  Shadow Paging cleanup.
	if (shadowPaging != NULL)
		pfree(shadowPaging);

	return 0;
}
Esempio n. 4
0
void Interface::configChanged()
{
    KSharedConfigPtr config = KGlobal::config();
    QString group( confg_interface );
    group += mIfaceName;
    KConfigGroup interfaceGroup( config, group );
    InterfaceSettings s;
    mSettings.alias = interfaceGroup.readEntry( conf_alias ).trimmed();
    mSettings.iconTheme = interfaceGroup.readEntry( conf_iconTheme, s.iconTheme );
    QStringList themeNames;
    QList<KNemoTheme> themes = findThemes();
    // Let's check that it's available
    foreach( KNemoTheme theme, themes )
        themeNames << theme.internalName;
    themeNames << NETLOAD_THEME;
    if ( !themeNames.contains( mSettings.iconTheme ) )
        mSettings.iconTheme = TEXT_THEME;
    mSettings.colorIncoming = interfaceGroup.readEntry( conf_colorIncoming, s.colorIncoming );
    mSettings.colorOutgoing = interfaceGroup.readEntry( conf_colorOutgoing, s.colorOutgoing );
    KColorScheme scheme(QPalette::Active, KColorScheme::View);
    mSettings.colorDisabled = interfaceGroup.readEntry( conf_colorDisabled, scheme.foreground( KColorScheme::InactiveText ).color() );
    mSettings.colorUnavailable = interfaceGroup.readEntry( conf_colorUnavailable, scheme.foreground( KColorScheme::InactiveText ).color() );
    mSettings.colorBackground = scheme.foreground( KColorScheme::InactiveText ).color();
    mSettings.iconFont = interfaceGroup.readEntry( conf_iconFont, s.iconFont );
    mSettings.dynamicColor = interfaceGroup.readEntry( conf_dynamicColor, s.dynamicColor );
    mSettings.colorIncomingMax = interfaceGroup.readEntry( conf_colorIncomingMax, s.colorIncomingMax );
    mSettings.colorOutgoingMax = interfaceGroup.readEntry( conf_colorOutgoingMax, s.colorOutgoingMax );
    mSettings.barScale = interfaceGroup.readEntry( conf_barScale, s.barScale );
    mSettings.inMaxRate = interfaceGroup.readEntry( conf_inMaxRate, s.inMaxRate )*1024;
    mSettings.outMaxRate = interfaceGroup.readEntry( conf_outMaxRate, s.outMaxRate )*1024;
    mSettings.hideWhenDisconnected = interfaceGroup.readEntry( conf_hideWhenNotAvail, s.hideWhenDisconnected );
    mSettings.hideWhenUnavailable = interfaceGroup.readEntry( conf_hideWhenNotExist, s.hideWhenUnavailable );
    mSettings.activateStatistics = interfaceGroup.readEntry( conf_activateStatistics, s.activateStatistics );
    mSettings.trafficThreshold = clamp<unsigned int>(interfaceGroup.readEntry( conf_trafficThreshold, s.trafficThreshold ), 0, 1000 );
    mSettings.warnRules.clear();
    int warnRuleCount = interfaceGroup.readEntry( conf_warnRules, 0 );
    for ( int i = 0; i < warnRuleCount; ++i )
    {
        group = QString( "%1%2 #%3" ).arg( confg_warnRule ).arg( mIfaceName ).arg( i );
        if ( config->hasGroup( group ) )
        {
            KConfigGroup warnGroup( config, group );
            WarnRule warn;
            warn.periodUnits = clamp<int>(warnGroup.readEntry( conf_warnPeriodUnits, warn.periodUnits ), KNemoStats::Hour, KNemoStats::Year );
            warn.periodCount = clamp<int>(warnGroup.readEntry( conf_warnPeriodCount, warn.periodUnits ), 1, 1000 );
            warn.trafficType = clamp<int>(warnGroup.readEntry( conf_warnTrafficType, warn.trafficType ), KNemoStats::Peak, KNemoStats::PeakOffpeak );
            warn.trafficDirection = clamp<int>(warnGroup.readEntry( conf_warnTrafficDirection, warn.trafficDirection ), KNemoStats::TrafficIn, KNemoStats::TrafficTotal );
            warn.trafficUnits = clamp<int>(warnGroup.readEntry( conf_warnTrafficUnits, warn.trafficUnits ), KNemoStats::UnitB, KNemoStats::UnitG );
            warn.threshold = clamp<double>(warnGroup.readEntry( conf_warnThreshold, warn.threshold ), 0.0, 9999.0 );
            warn.customText = warnGroup.readEntry( conf_warnCustomText, warn.customText ).trimmed();

            mSettings.warnRules << warn;
        }
    }

    if ( interfaceGroup.hasKey( conf_calendar ) )
    {
        QString oldSetting = interfaceGroup.readEntry( conf_calendar );
        mSettings.calendarSystem = KCalendarSystem::calendarSystem( oldSetting );
        interfaceGroup.writeEntry( conf_calendarSystem, static_cast<int>(mSettings.calendarSystem) );
        interfaceGroup.deleteEntry( conf_calendar );
        config->sync();
    }
    else
        mSettings.calendarSystem = static_cast<KLocale::CalendarSystem>(interfaceGroup.readEntry( conf_calendarSystem, static_cast<int>(KLocale::QDateCalendar) ));

    mSettings.statsRules.clear();
    int statsRuleCount = interfaceGroup.readEntry( conf_statsRules, 0 );
    KCalendarSystem *testCal = KCalendarSystem::create( mSettings.calendarSystem );
    for ( int i = 0; i < statsRuleCount; ++i )
    {
        group = QString( "%1%2 #%3" ).arg( confg_statsRule ).arg( mIfaceName ).arg( i );
        if ( config->hasGroup( group ) )
        {
            KConfigGroup statsGroup( config, group );
            StatsRule rule;

            rule.startDate = statsGroup.readEntry( conf_statsStartDate, QDate() );
            rule.periodUnits = clamp<int>(statsGroup.readEntry( conf_statsPeriodUnits, rule.periodUnits ), KNemoStats::Day, KNemoStats::Year );
            rule.periodCount = clamp<int>(statsGroup.readEntry( conf_statsPeriodCount, rule.periodCount ), 1, 1000 );
            rule.logOffpeak = statsGroup.readEntry( conf_logOffpeak,rule.logOffpeak );
            rule.offpeakStartTime = QTime::fromString( statsGroup.readEntry( conf_offpeakStartTime, rule.offpeakStartTime.toString( Qt::ISODate ) ), Qt::ISODate );
            rule.offpeakEndTime = QTime::fromString( statsGroup.readEntry( conf_offpeakEndTime, rule.offpeakEndTime.toString( Qt::ISODate ) ), Qt::ISODate );
            rule.weekendIsOffpeak = statsGroup.readEntry( conf_weekendIsOffpeak, rule.weekendIsOffpeak );
            rule.weekendDayStart = clamp<int>(statsGroup.readEntry( conf_weekendDayStart, rule.weekendDayStart ), 1, testCal->daysInWeek( QDate::currentDate() ) );
            rule.weekendDayEnd = clamp<int>(statsGroup.readEntry( conf_weekendDayEnd, rule.weekendDayEnd ), 1, testCal->daysInWeek( QDate::currentDate() ) );
            rule.weekendTimeStart = QTime::fromString( statsGroup.readEntry( conf_weekendTimeStart, rule.weekendTimeStart.toString( Qt::ISODate ) ), Qt::ISODate );
            rule.weekendTimeEnd = QTime::fromString( statsGroup.readEntry( conf_weekendTimeEnd, rule.weekendTimeEnd.toString( Qt::ISODate ) ), Qt::ISODate );
            if ( rule.isValid( testCal ) )
            {
                mSettings.statsRules << rule;
            }
        }
    }

    mSettings.commands.clear();
    int numCommands = interfaceGroup.readEntry( conf_numCommands, s.numCommands );
    for ( int i = 0; i < numCommands; i++ )
    {
        QString entry;
        InterfaceCommand cmd;
        entry = QString( "%1%2" ).arg( conf_runAsRoot ).arg( i + 1 );
        cmd.runAsRoot = interfaceGroup.readEntry( entry, false );
        entry = QString( "%1%2" ).arg( conf_command ).arg( i + 1 );
        cmd.command = interfaceGroup.readEntry( entry );
        entry = QString( "%1%2" ).arg( conf_menuText ).arg( i + 1 );
        cmd.menuText = interfaceGroup.readEntry( entry );
        mSettings.commands.append( cmd );
    }

    // This prevents needless regeneration of icon when first shown in tray
    if ( mIfaceState == KNemoIface::UnknownState )
    {
        mIfaceState = mBackendData->status;
        mPreviousIfaceState = mIfaceState;
    }
    mIcon.configChanged();

    if ( mIfaceStatistics )
    {
        mIfaceStatistics->configChanged();
        if ( !mSettings.activateStatistics )
            stopStatistics();
    }
    else if ( mSettings.activateStatistics )
    {
        startStatistics();
    }

    if ( mStatusDialog )
        mStatusDialog->configChanged();
    if ( mStatisticsDialog != 0 )
        mStatisticsDialog->configChanged();
    if ( mPlotterDialog )
        mPlotterDialog->useBitrate( generalSettings->useBitrate );
}