char * cpu_linux::fill_cstate_line(int line_nr, char *buffer, const char *separator)
{
	unsigned int i;
	buffer[0] = 0;

	if (line_nr == LEVEL_HEADER) {
		sprintf(buffer,_(" CPU %i"), number);
		return buffer;
	}

	for (i = 0; i < cstates.size(); i++) {
		if (cstates[i]->line_level != line_nr)
			continue;

		if (line_nr == LEVEL_C0)
			sprintf(buffer,"%5.1f%%", percentage(cstates[i]->duration_delta / time_factor));
		else
			sprintf(buffer,"%5.1f%%%s %6.1f ms",
				percentage(cstates[i]->duration_delta / time_factor),
				separator,
				1.0 * cstates[i]->duration_delta / (1 + cstates[i]->usage_delta) / 1000);
	}

	return buffer;
}
Exemplo n.º 2
0
void BallsUIImpl::DTChanged(int) {
  DTLabel->setText (
    QString::number (
		     0.00001*pow (10, percentage (DTSlider)*5.),
		     'g', 3));
  BW->setDeltaT (0.00001*pow (10, percentage (DTSlider)*5.));
}
Exemplo n.º 3
0
//--------------------------------------------------------------
void ofxTeensyOcto::update()
{
    if(simulate) return;

    // send our data via serial
    for (int i=0; i < numPorts; i++)
    {
        // copy a portion of the movie's image to the LED image
        float xoffset = percentage(ledWidth, ledArea[i].x);
        float yoffset = percentage((ledHeight * stripsPerPort * numPortsMain), ledArea[i].y);
        float xwidth =  percentage(ledWidth, ledArea[i].getWidth());
        float yheight = percentage((ledHeight * stripsPerPort * numPortsMain), ledArea[i].getHeight());

        // crop the pixels
        ledImage[i].setFromPixels(pixels1);
        ledImage[i].crop(xoffset, yoffset, xwidth, yheight);

        image2data(ledImage[i], ledData, ledLayout[i]);

        ledData[0] = '*';  // first Teensy is the frame sync master

        int nBytesWritten = 0;
        while (nBytesWritten < dataSize){
            nBytesWritten += ledSerial[i].writeBytes( &ledData[nBytesWritten], dataSize );
        }
    }
}
TEST(CSSTokenizerTest, PercentageToken)
{
    TEST_TOKENS("10%", percentage(IntegerValueType, 10));
    TEST_TOKENS("+12.0%", percentage(NumberValueType, 12));
    TEST_TOKENS("-48.99%", percentage(NumberValueType, -48.99));
    TEST_TOKENS("6e-1%", percentage(NumberValueType, 0.6));
    TEST_TOKENS("5%%", percentage(IntegerValueType, 5), delim('%'));
}
Exemplo n.º 5
0
void ExpandingSphereAnimation::draw(const ClockState &state) {
  ofPushStyle();

  ofFloatColor color = _color;
  color.a *= _params.alpha.evaluate(percentage());
  ofSetColor(color);
  ofDrawSphere(_position, _params.radius.evaluate(percentage()));

  ofPopStyle();
}
Exemplo n.º 6
0
void Battery::changed() {
    emit monitoring( tr( "%1 : Properties changed").arg( m_path ) );
    int level = percentage();
    if( level < lowLevel() ) {
        if( ! m_hasAlreadyBeenLow ) {
            m_hasAlreadyBeenLow = true;
            emit lowBattery(this);
            emit monitoring( tr( "%1 : Low" ).arg( m_path ) );
        }
    } else {
        m_hasAlreadyBeenLow = false;
    }

    if( state() == FullyCharged ) {
        if( ! m_hasAlreadyBeenFull ) {
            m_hasAlreadyBeenFull = true;
            emit full(this);
            emit monitoring( tr( "%1 : Full" ).arg( m_path ) );
        }
    } else {
        m_hasAlreadyBeenFull = false;
    }
    //m_view->refresh();
    emit changed(this);
}
Exemplo n.º 7
0
char * cpu_package::fill_pstate_line(int line_nr, char *buffer)
{
    buffer[0] = 0;
    unsigned int i;

    if (total_stamp ==0) {
        for (i = 0; i < pstates.size(); i++)
            total_stamp += pstates[i]->time_after;
        if (total_stamp == 0)
            total_stamp = 1;
    }


    if (line_nr == LEVEL_HEADER) {
        sprintf(buffer,_("  Package"));
        return buffer;
    }

    if (line_nr >= (int)pstates.size() || line_nr < 0)
        return buffer;


    sprintf(buffer," %5.1f%% ", percentage(1.0* (pstates[line_nr]->time_after) / total_stamp));
    return buffer;
}
Exemplo n.º 8
0
char *pretty_freespace(const char *desc, unsigned long long *free_k, unsigned long long *total_k)
{
	char *quantities[] = { "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB", 0 };
	char *result, **quantity;
	double free_space, total_space;
	free_space = *free_k;
	total_space = *total_k;
	result = static_cast<char*>(malloc(bsize * sizeof(char)));
	if (total_space == 0)
	{
		snprintf(result, bsize, "%s: none", desc);
		return result;
	}
        quantity = quantities;
	while (total_space > 1023 && *(quantity + 1))
	{
		quantity++;
		free_space = free_space / 1024;
		total_space = total_space / 1024;
	}
	if (sysinfo_get_percent () != 0)
		snprintf(result, bsize, "%s: %.1f%s, %.1f%% free",
		desc, total_space, *quantity,
		percentage(free_k, total_k));
	else
		snprintf(result, bsize, "%s: %.1f%s/%.1f%s free",
		desc, free_space, *quantity, total_space, *quantity);
        return result;
}
Exemplo n.º 9
0
char * nhm_cpu::fill_pstate_line(int line_nr, char *buffer)
{
	if (total_stamp ==0) {
		unsigned int i;
		for (i = 0; i < pstates.size(); i++)
			total_stamp += pstates[i]->time_after;
		if (total_stamp == 0)
			total_stamp = 1;
	}

	if (line_nr == LEVEL_HEADER) {
		sprintf(buffer,_(" CPU %i"), number);
		return buffer;
	}

	if (line_nr == LEVEL_C0) {
		double F;
		F = 1.0 * (tsc_after - tsc_before) * (aperf_after - aperf_before) / (mperf_after - mperf_before) / time_factor * 1000;
		hz_to_human(F, buffer, 1);
		return buffer;
	}
	if (line_nr >= (int)pstates.size() || line_nr < 0)
		return buffer;

	sprintf(buffer," %5.1f%% ", percentage(1.0* (pstates[line_nr]->time_after) / total_stamp));
	return buffer;

}
Exemplo n.º 10
0
char *pretty_freespace(const char *desc, unsigned long long *free_k, unsigned long long *total_k)
{
        char *result, *bytesize;
	double free_space, total_space;
	free_space = *free_k;
	total_space = *total_k;
        result = malloc(bsize * sizeof(char));
	const char *quantities = "KB\0MB\0GB\0TB\0PB\0EB\0ZB\0YB\0";
	int i=0;
	if (total_space == 0)
	{
		snprintf(result, bsize, "%s: none", desc);
		return result;
	}
        bytesize = malloc(3 * sizeof(char));
	while (total_space > 1023 && i <= 14)
	{
		i=i+3;
		*bytesize=*(quantities+i);
		*(bytesize+1)=*(quantities+i+1);
		*(bytesize+2)=*(quantities+i+2);
		free_space = free_space / 1024;
		total_space = total_space / 1024;
	}
	if (sysinfo_get_percent () != 0)
		snprintf(result, bsize, "%s: %.1f%s, %.1f%% free",
		desc, total_space, bytesize,
		percentage(free_k, total_k));
	else
		snprintf(result, bsize, "%s: %.1f%s/%.1f%s free",
		desc, free_space, bytesize, total_space, bytesize);
	free (bytesize);
        return result;
}
Exemplo n.º 11
0
int main () {
    double * log = natural_log ();
    double * approx = approximation ();
    double * percent = percentage(log, approx);
    file_output (log, approx, percent);
    return 0;
}
Exemplo n.º 12
0
char * nhm_core::fill_pstate_line(int line_nr, char *buffer)
{
	const int intel_pstate = is_intel_pstate_driver_loaded();
	buffer[0] = 0;
	unsigned int i;

	if (!intel_pstate && total_stamp ==0) {
		for (i = 0; i < pstates.size(); i++)
			total_stamp += pstates[i]->time_after;
		if (total_stamp == 0)
			total_stamp = 1;
	}

	if (line_nr == LEVEL_HEADER) {
		sprintf(buffer,_("  Core"));
		return buffer;
	}

	if (intel_pstate > 0 || line_nr >= (int)pstates.size() || line_nr < 0)
		return buffer;

	sprintf(buffer," %5.1f%% ", percentage(1.0* (pstates[line_nr]->time_after) / total_stamp));

	return buffer;
}
Exemplo n.º 13
0
void KNProgressSlider::paintEvent(QPaintEvent *event)
{
    KNAbstractSlider::paintEvent(event);
    //Initial painter.
    QPainter painter(this);
    //Set antialiasing.
    painter.setRenderHint(QPainter::Antialiasing, true);
    painter.setRenderHint(QPainter::TextAntialiasing, true);
    painter.setRenderHint(QPainter::SmoothPixmapTransform, true);

    //Using background opacity to draw the slider background.
    painter.setOpacity(m_backOpacity);

    //Set no pen
    painter.setPen(Qt::NoPen);

    //Draw central rects.
    painter.setBrush(m_rectColor);
    painter.drawRect(m_glowWidth,
                     m_glowWidth+m_spacing,
                     width()-(m_glowWidth<<1),
                     m_sliderHeight);

    //If range is not 0, draw the button.
    if(range()>0)
    {
        //Restore the opacity.
        painter.setOpacity(1.0);

        //Get the current position.
        int positionLeft=percentage()*(float)(width()-m_buttonSize);
        //Paint the rect.
        painter.setBrush(m_buttonColor);
        painter.drawRect(m_glowWidth,
                         m_glowWidth+m_spacing,
                         positionLeft,
                         m_sliderHeight);


        //Draw the circle button.
        painter.save();
        //Calculate position.
        painter.translate(positionLeft,
                          m_spacing);
        //Set the gradient.
        int buttonCenter=m_glowWidth+(m_sliderHeight>>1);
        QRadialGradient buttonGradient=QRadialGradient(QPointF(buttonCenter, buttonCenter),
                                                       buttonCenter,
                                                       QPointF(buttonCenter, buttonCenter));
        buttonGradient.setColorAt(0, QColor(255,255,255,200));
        buttonGradient.setColorAt(1, QColor(255,255,255,0));
        painter.setBrush(buttonGradient);
        painter.drawEllipse(0,0,height(),height());
        //Set the color.
        painter.setBrush(m_backgroundColor);
        painter.drawEllipse(m_glowWidth-1, m_glowWidth-1, m_sliderHeight+2, m_sliderHeight+2);
        //Restore transform.
        painter.restore();
    }
Exemplo n.º 14
0
 std::string percentage_str(int64_t value) const
 {
     boost::format percent_fmt("%4.1f%%");
     percent_fmt % (percentage(value) * 100);
     std::string s = percent_fmt.str();
     s.resize(4);
     return s;
 }
Exemplo n.º 15
0
void RadiusOutlierRemoval:: execute()
{
    pcl::PointCloud<pcl::PointXYZI>::Ptr cloudNewTerrain (new pcl::PointCloud<pcl::PointXYZI>);
emit percentage(1);
    // Create the filtering object
    pcl::RadiusOutlierRemoval<pcl::PointXYZI> ror;
    ror.setInputCloud (m_baseCloud->get_Cloud());
    ror.setRadiusSearch(m_radius);
    ror.setMinNeighborsInRadius(m_neighbors);
    ror.filter (*cloudNewTerrain);
emit percentage(50);
    cloudNewTerrain->width = cloudNewTerrain->points.size ();
    cloudNewTerrain->height = 1;
    cloudNewTerrain->is_dense = true;

    m_output->set_Cloud(cloudNewTerrain);
emit percentage(100);
    sendData();

}
Exemplo n.º 16
0
void StatOutlierRemoval:: execute()
{
    pcl::PointCloud<pcl::PointXYZI>::Ptr cloudNewTerrain (new pcl::PointCloud<pcl::PointXYZI>);
emit percentage(1);
    // Create the filtering object
    pcl::StatisticalOutlierRemoval<pcl::PointXYZI> sor;
    sor.setInputCloud (m_baseCloud->get_Cloud());
    sor.setMeanK (m_neighbors);
    sor.setStddevMulThresh (m_mDist);
    sor.filter (*cloudNewTerrain);
emit percentage(70);
    cloudNewTerrain->width = cloudNewTerrain->points.size ();
    cloudNewTerrain->height = 1;
    cloudNewTerrain->is_dense = true;

    m_output->set_Cloud(cloudNewTerrain);
emit percentage(100);
    sendData();

}
Exemplo n.º 17
0
int
virtual_memory(VmemInfo *ret)
{
  struct sysinfo info;
  FILE *fp = NULL;
  unsigned long long totalram, freeram, bufferram;
  unsigned long long cached = -1, active = -1, inactive = -1;
  char *line = (char *)calloc(50, sizeof(char));
  check_mem(line);
  check(sysinfo(&info) == 0, "sysinfo failed");
  totalram  = info.totalram  * info.mem_unit;
  freeram   = info.freeram  * info.mem_unit;
  bufferram = info.bufferram  * info.mem_unit;

  fp = fopen("/proc/meminfo", "r");
  check(fp, "Couldn't open /proc/meminfo");
  while (fgets(line, 40, fp) != NULL) {
    if (strncmp(line, "Cached:", 7) == 0){
      strtok(line, ":"); /* Drop "Cached:" */
      cached = strtoull(strtok(NULL, " "), NULL, 10);
    }
    if (strncmp(line, "Active:", 7) == 0){
      strtok(line, ":"); /* Drop "Active:" */
      active = strtoull(strtok(NULL, " "), NULL, 10);
    }
    if (strncmp(line, "Inactive:", 7) == 0){
      strtok(line, ":"); /* Drop "Inactive:" */
      inactive = strtoull(strtok(NULL, " "), NULL, 10);
    }
  }
  if (cached == -1 || active == -1 || inactive == -1) {
    log_warn("Couldn't determine 'cached', 'active' and 'inactive' memory stats. Setting them to 0");
    cached = active = inactive = 0;
  }
  fclose(fp);
  free(line);

  ret->total = totalram;
  ret->available = freeram + bufferram + cached;
  ret->percent = percentage((totalram - ret->available), totalram);
  ret->used = totalram - freeram;
  ret->free = freeram;
  ret->active = active;
  ret->inactive = inactive;
  ret->buffers = bufferram;
  ret->cached = cached;

  return 0;
 error:
  if(fp) fclose(fp);
  if (line) free(line);
  return -1;
}
void UT_CMccJitterCalculator::UT_CMccJitterCalculator_CountPacketLossPercentageL()
    {
    TInt percentage( 0 );
    
    iCalculator->iHomeTime.HomeTime();
    
    // Not active
    iCalculator->JitterObserving();
    
    iCalculator->iPrevFerValue = 0;
    iCalculator->iStartingSeqNum = 80;
    iCalculator->iCurrentSeqNum = 100;
    
    // no packets lost
    iCalculator->iPrevExpectedPackets = 20;
    iCalculator->iReceivedPacketCounter = 20;

    iCalculator->CountPacketLossPercentage();
    
    EUNIT_ASSERT_EQUALS( iCalculator->iPrevFerValue, 0 );
    EUNIT_ASSERT_EQUALS( iCalculator->iPrevExpectedPackets, 20 );
    EUNIT_ASSERT_EQUALS( iCalculator->iPrevPacketsReceived, 20 );
    
    
    // no packets lost, inorder
    iCalculator->iCurrentSeqNum = 102;  
    iCalculator->iPrevExpectedPackets = 22;

    iCalculator->CountPacketLossPercentage();
    
    EUNIT_ASSERT_EQUALS( iCalculator->iPrevFerValue, 0 );
    EUNIT_ASSERT_EQUALS( iCalculator->iPrevExpectedPackets, 22 );
    EUNIT_ASSERT_EQUALS( iCalculator->iPrevPacketsReceived, 20 );
    
	
    // packet  lost - add FER by number of packets lost.
    // 5 packets lost
    iCalculator->iPrevFerValue = 0;
    iCalculator->iStartingSeqNum = 80;
    iCalculator->iCurrentSeqNum = 105;

    iCalculator->iPrevExpectedPackets = 20;
    iCalculator->iReceivedPacketCounter = 20;

    percentage = iCalculator->CountPacketLossPercentage();
    
    EUNIT_ASSERT_EQUALS( percentage, 1 );
    EUNIT_ASSERT_EQUALS( iCalculator->iPrevFerValue, 7952 );
    EUNIT_ASSERT_EQUALS( iCalculator->iPrevExpectedPackets, 25 );
    EUNIT_ASSERT_EQUALS( iCalculator->iPrevPacketsReceived, 20 );
    }
Exemplo n.º 19
0
const Rect Option::getGeometry(const Rect &ref) const
{
	int t,l,w,h;
	t = l = w = h = 0;
	char *v = value;
	w = strtol(v, &v, 10);
	if (*v == '%') w = percentage(w, ref.width()), ++v;
	if (*v == 'x') {
		h = strtol(v + 1, &v, 10);
		if (*v == '%') h = percentage(h, ref.height()), ++v;
		if (*v == '+' || *v == '-')
			l = strtol(v, &v, 10);
		if (*v == '%') l = percentage(l, ref.width()), ++v;
	}
	else
		l = w, w = 0;
	if (*v == '+' || *v == '-')
		t = strtol(v, &v, 10);
	if (*v == '%') t = percentage(t, ref.height()), ++v;
	if (l < 0) l = ref.width() + l - w;
	if (t < 0) t = ref.height() + t - h;
	return Rect(l, t, l + w, t + h);
}
Exemplo n.º 20
0
char * cpu_package::fill_cstate_line(int line_nr, char *buffer, const char *separator)
{
	unsigned int i;
	buffer[0] = 0;

	for (i = 0; i < cstates.size(); i++) {
		if (cstates[i]->line_level != line_nr)
			continue;

		sprintf(buffer,"%5.1f%%", percentage(cstates[i]->duration_delta / time_factor));
	}

	return buffer;
}
Exemplo n.º 21
0
/* Public functions */
bool disk_usage(const char path[], DiskUsage *ret) {
  struct statvfs s;
  int r;
  r = statvfs(path, &s);
  check(r == 0, "Error in calling statvfs for %s", path);
  ret->free = s.f_bavail * s.f_frsize;
  ret->total = s.f_blocks * s.f_frsize;
  ret->used = (s.f_blocks - s.f_bfree) * s.f_frsize;
  ret->percent = percentage(ret->used, ret->total);

  return true;
error:
  return false;
}
int main ()
{
	int message [7] = {0};
	percentage("hello world",message);
	printf("The number of control     character:%d\n",message[0]);
	printf("The number of space       character:%d\n",message[1]);
	printf("The number of digit       character:%d\n",message[2]);
	printf("The number of lower       character:%d\n",message[3]);
	printf("The number of upper       character:%d\n",message[4]);
	printf("The number of punctuation character:%d\n",message[5]);
	printf("The number of unable to be print character:%d\n",message[6]);
	getchar();
	return 0;
}
Exemplo n.º 23
0
void OctreeTerrain:: execute()
{

//qWarning()<<"octree terrain starts";
emit percentage( 5);

    pcl::PointCloud<pcl::PointXYZI>::Ptr cloud_tmp(new pcl::PointCloud<pcl::PointXYZI>);
    pcl::PointCloud<pcl::PointXYZI>::Ptr cloud_tmp2(new pcl::PointCloud<pcl::PointXYZI>);
    pcl::PointCloud<pcl::PointXYZI>::Ptr cloud_tmp3(new pcl::PointCloud<pcl::PointXYZI>);
    pcl::PointCloud<pcl::PointXYZI>::Ptr cloud_tmp4(new pcl::PointCloud<pcl::PointXYZI>);

      //velky cyklus
emit percentage( 10);
    octree(m_resolution*5, m_baseCloud->get_Cloud(), cloud_tmp, cloud_tmp2);
emit percentage( 70);
    octree(m_resolution/2, cloud_tmp2, cloud_tmp3, cloud_tmp4);
emit percentage( 80);
    *cloud_tmp += *cloud_tmp3;
    m_vegetation->set_Cloud(cloud_tmp);
    m_terrain->set_Cloud(cloud_tmp4);
emit percentage( 90);
      sendData();
}
Exemplo n.º 24
0
bool swap_memory(SwapMemInfo *ret) {
  struct sysinfo info;
  FILE *fp = NULL;
  char *line = NULL;

  unsigned long totalswap, freeswap, usedswap;
  unsigned long sin = ULONG_MAX, sout = ULONG_MAX;
  check(sysinfo(&info) == 0, "sysinfo failed");

  totalswap = info.totalswap;
  freeswap = info.freeswap;
  usedswap = totalswap - freeswap;

  fp = fopen("/proc/vmstat", "r");
  check(fp, "Couldn't open /proc/vmstat");

  line = (char *)calloc(50, sizeof(char));
  check_mem(line);

  while (fgets(line, 40, fp) != NULL) {
    if (strncmp(line, "pswpin", 6) == 0) {
      sin = strtoul(line + 7, NULL, 10) * 4 * 1024;
    }
    if (strncmp(line, "pswpout", 7) == 0) {
      sout = strtoul(line + 8, NULL, 10) * 4 * 1024;
    }
  }
  if (sin == ULONG_MAX || sout == ULONG_MAX) {
    log_warn(
        "Couldn't determine 'sin' and 'sout' swap stats. Setting them to 0");
    sout = sin = 0;
  }
  fclose(fp);
  free(line);

  ret->total = totalswap;
  ret->used = usedswap;
  ret->free = freeswap;
  ret->percent = percentage(usedswap, totalswap);
  ret->sin = sin;
  ret->sout = sout;

  return true;
error:
  if (fp)
    fclose(fp);
  free(line);
  return false;
}
Exemplo n.º 25
0
int FileLoader::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QThread::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: status((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 1: percentage((*reinterpret_cast< qint64(*)>(_a[1]))); break;
        case 2: progressRange((*reinterpret_cast< qint64(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 3;
    }
    return _id;
}
Exemplo n.º 26
0
	void BorderBar::paintEvent(QPaintEvent *)
	{
		QRectF rect(2, 2, width()-4, height()-4);
		QPainter painter(this);
		painter.setRenderHint(QPainter::Antialiasing, true);		//	边缘平滑..

		painter.setBrush(backgroundColor());
		painter.setPen(Qt::NoPen);
		painter.drawEllipse(rect);
		painter.setBrush(Qt::NoBrush);

		m_pen.setColor(foregroundColor());
		m_pen.setWidth(4);
		painter.setPen(m_pen);

		painter.drawArc(rect, 0.25 * RADIAN, -percentage() * RADIAN);	//	+: 逆时针 -: 顺时针
		DRAWTEXT(painter, m_pen, m_font);		//	绘画文字..
	}
Exemplo n.º 27
0
void WProgressBar::updateDom(DomElement& element, bool all)
{
  DomElement *bar = 0, *label = 0;

  if (all) {
    WApplication *app = WApplication::instance();

    bar = DomElement::createNew(DomElement_DIV);
    bar->setId("bar" + id());
    bar->setProperty(PropertyClass, valueStyleClass_);
    app->theme()->apply(this, *bar, ProgressBarBarRole);

    label = DomElement::createNew(DomElement_DIV);
    label->setId("lbl" + id());
    app->theme()->apply(this, *label, ProgressBarLabelRole);
  }

  if (changed_ || all) {
    if (!bar)
      bar = DomElement::getForUpdate("bar" + id(), DomElement_DIV);
    if (!label)
      label = DomElement::getForUpdate("lbl" + id(), DomElement_DIV);

    bar->setProperty(PropertyStyleWidth,
		     boost::lexical_cast<std::string>(percentage()) + "%");

    WString s = text();
    removeScript(s);

    label->setProperty(PropertyInnerHTML, s.toUTF8());

    changed_ = false;
  }

  if (bar)
    element.addChild(bar);

  if (label)
    element.addChild(label);

  WInteractWidget::updateDom(element, all);
}
Exemplo n.º 28
0
void output_comparison(COMPARISON comp)
{
	puts("--------------------------------------------------------");
	printf("%s\t-\t%s\t%6.2f%%\n", comp->a->filename, comp->b->filename, comp->overall*100);
	if ( ! quiet_flag )
	{
	  printf(_("\tTiles: %d, Sum: %d\n"), comp->atom_tiles->num, comp->atom_tiles->sum_lengths);
	  if ( use_metric != 2 )
  		output_tiles(comp, comp->atom_tiles);
  	  if ( use_metric )
	  {
		printf(_("Metrics values: \n"));
	    int num_metrics = sizeof(struct metrics) / sizeof(int), i;
	    int *metr_a = (int*) &comp->a->theMetrics;
	    int *metr_b = (int*) &comp->b->theMetrics;
	    for(i=0; i < num_metrics; i++)
			printf("  %4d - %4d  %10s %%\n", metr_a[i], metr_b[i], percentage(metr_a[i], metr_b[i]));
	  }  
	}
}
Exemplo n.º 29
0
std::string ScopeTimerResults::timer_results()
{
	ScopeTimeFunction();
	std::map<const char *, bool> result_names;
	for (size_t i = 0; i < instance.results.size(); i++)
		result_names[instance.results[i].name] = true;

	std::string final_results;
	for (std::map<const char *, bool>::iterator it = result_names.begin(); it != result_names.end(); ++it)
	{
		int time_spent = percentage(it->first);
		if (time_spent > 0)
		{
			if (!final_results.empty())
				final_results += "\n";
			final_results += string_format("%1: %2%%", it->first, time_spent);
		}
	}
	return final_results;
}
Exemplo n.º 30
0
__int64 CDupFileFilter::CompareFiles(HANDLE pFiles[], unsigned int nFiles)
{
	__int64 pos = FileSize(pFiles[0]);
	char buffer1[4096];
	DWORD nRead1 = sizeof(buffer1)/sizeof(char);
	bool bUpdateProgress = pos >= 1024*1024; // 1Mb
	CPercentage percentage(pos, FileCompareUpdateCallback, m_pDialog);
	pos = 0;
	while (ReadFile(pFiles[0], buffer1, nRead1, &nRead1, NULL) && nRead1 > 0) {
		pos += nRead1;
		for (unsigned int i=1; i < nFiles; ++i) {
			char buffer2[4096];
			ReadFile(pFiles[i], buffer2, nRead1, &nRead1, NULL);
			if (nRead1 == 0 || memcmp(buffer1, buffer2, nRead1)) {
				return pos;
			}
		}
		if (bUpdateProgress)
			percentage.Update(pos);
	}
	return 0;
}