示例#1
0
TEST_F(Benchmark, ZeroMQ)
{
    TIMER_START(1000000);
    ::zmq::message_t *msg = new ::zmq::message_t();
    delete msg;
    TIMER_END("zmq.empty_message_allocation");

    TIMER_START(1000000);
    ::zmq::message_t *msg = new ::zmq::message_t(100);
    delete msg;
    TIMER_END("zmq.100_byte_message_allocation");

    TIMER_START(1000000);
    ::zmq::message_t *msg = new ::zmq::message_t(1000);
    delete msg;
    TIMER_END("zmq.1000_byte_message_allocation");

    TIMER_START(100000);
    ::zmq::message_t *msg = new ::zmq::message_t(10000);
    delete msg;
    TIMER_END("zmq.10000_byte_message_allocation");

    TIMER_START(10000);
    ::zmq::message_t *msg = new ::zmq::message_t(100000);
    delete msg;
    TIMER_END("zmq.100000_byte_message_allocation");

    zmq_socket_send_recv("inproc://00", ZMQ_PUSH, ZMQ_PULL, 0, 1000000, "zmq.socket.inproc.pushpull.empty");
    zmq_socket_send_recv("inproc://01", ZMQ_PUSH, ZMQ_PULL, 100, 1000000, "zmq.socket.inproc.pushpull.100_byte_message");
    zmq_socket_send_recv("inproc://02", ZMQ_PUSH, ZMQ_PULL, 1000, 1000000, "zmq.socket.inproc.pushpull.1000_byte_message");
    zmq_socket_send_recv("inproc://03", ZMQ_PUSH, ZMQ_PULL, 10000, 1000000, "zmq.socket.inproc.pushpull.10000_byte_message");
    zmq_socket_send_recv("inproc://04", ZMQ_PUSH, ZMQ_PULL, 100000, 100000, "zmq.socket.inproc.pushpull.100000_byte_message");
    zmq_socket_send_recv("inproc://05", ZMQ_PUSH, ZMQ_PULL, 1000000, 100000, "zmq.socket.inproc.pushpull.1000000_byte_message");
}
示例#2
0
void IR_state (uint8_t nextState)
{
    switch (nextState) {
    case IR_IDLE:
        IR_TX_OFF();
        IR_COMPARE_DISABLE();

        // 1st interrupt when receiving ir must be falling edge
        IR_CAPTURE_FALL();
        IR_CAPTURE_ENABLE();

        IR_clear();
        break;
    case IR_RECVING:
        IR_clear();
        TIMER_START( IrCtrl.recv_timer, RECV_TIMEOUT );
        break;
    case IR_RECVED:
        TIMER_STOP( IrCtrl.recv_timer );

        irpacker_packend( &packer_state );

        // disable til IRKit.cpp reports IR data to server
        IR_CAPTURE_DISABLE();
        IR_COMPARE_DISABLE();

        if (IrCtrl.len < VALID_IR_LEN_MIN) {
            // received, but probably noise
            IR_state( IR_IDLE );
            return;
        }
        break;
    case IR_RECVED_IDLE:
        // holds received IR data, and ready to receive next
        IR_CAPTURE_FALL();
        IR_CAPTURE_ENABLE();
        break;
    case IR_READING:
        irpacker_unpack_start( &packer_state );
        IR_CAPTURE_DISABLE();
        IR_COMPARE_DISABLE();
        break;
    case IR_WRITING:
        IR_CAPTURE_DISABLE();
        IR_COMPARE_DISABLE();
        IR_clear();
        break;
    case IR_XMITTING:
        IR_CAPTURE_DISABLE();
        IR_COMPARE_DISABLE();
        IrCtrl.tx_index = 0;
        TIMER_START( IrCtrl.xmit_timer, XMIT_TIMEOUT );
        break;
    case IR_DISABLED:
        IR_CAPTURE_DISABLE();
        IR_COMPARE_DISABLE();
        break;
    }
    IrCtrl.state = nextState;
}
void EdgeBasedGraphFactory::Run(const std::string &original_edge_data_filename,
                                const std::string &geometry_filename,
                                lua_State *lua_state)
{
    TIMER_START(geometry);
    CompressGeometry();
    TIMER_STOP(geometry);

    TIMER_START(renumber);
    RenumberEdges();
    TIMER_STOP(renumber);

    TIMER_START(generate_nodes);
    GenerateEdgeExpandedNodes();
    TIMER_STOP(generate_nodes);

    TIMER_START(generate_edges);
    GenerateEdgeExpandedEdges(original_edge_data_filename, lua_state);
    TIMER_STOP(generate_edges);

    m_geometry_compressor.SerializeInternalVector(geometry_filename);

    SimpleLogger().Write() << "Timing statistics for edge-expanded graph:";
    SimpleLogger().Write() << "Geometry compression: " << TIMER_SEC(geometry) << "s";
    SimpleLogger().Write() << "Renumbering edges: " << TIMER_SEC(renumber) << "s";
    SimpleLogger().Write() << "Generating nodes: " << TIMER_SEC(generate_nodes) << "s";
    SimpleLogger().Write() << "Generating edges: " << TIMER_SEC(generate_edges) << "s";
}
示例#4
0
double ProblemDescription::evaluateConstraint( const double * xi, 
                                                     double * h,
                                                     double * H )
{
    if ( factory.empty() ) {return 0; }

    TIMER_START( "constraint" );
    
    assert( h ); // make sure that h is not NULL
    
    prepareData( xi );
    
    MatMap h_map( h, factory.numOutput(), 1 );

    if ( !H ){ 
        const double val = factory.evaluate( trajectory, h_map );
        TIMER_STOP( "constraint" );
        return val;
    }
        
    MatMap H_map( H, trajectory.size(), factory.numOutput() );

    double magnitude = factory.evaluate(trajectory, h_map, H_map );

    if( doing_covariant ){
        //TODO find out if this is correct
        MatMap H_map2( H, trajectory.N(),
                       trajectory.M()*factory.numOutput() );
        metric.multiplyLowerInverse( H_map2 );
    }
    
    TIMER_STOP( "constraint" );
    return magnitude;
}
示例#5
0
文件: locinfo.c 项目: abrady/abscope
LocInfo* parse_add_locinfov(Parse *p,char *filename, int lineno, char *line, char *tag, char *referrer, char *context_in,va_list args)
{
    char buf[128];
    char *ctxt = context_in;
    LocInfo *l;
    TIMER_START();
    if(ctxt)
    {
        vsnprintf(buf,DIMOF(buf),ctxt,args);
        buf[DIMOF(buf)-1] = 0;
        ctxt = buf;
    }
    
    p->n_locs++;
    l           = ali_push(&p->locs);
    l->tag      = parse_find_add_str(p,tag);
    l->referrer = parse_find_add_str(p,referrer);
    l->context  = parse_find_add_str(p,ctxt);
    l->fname    = parse_find_add_str(p,filename);
    l->lineno   = lineno;
    l->line     = parse_find_add_str(p,line);

    TIMER_END(locinfo_timer);
    return l;
}
示例#6
0
int main(int argc, char** argv){

  int n;
  if (argc > 1)
    n = atoi(argv[1]);
  else
    n = 40;

  if (cilk_io_init()) {
    fprintf(stderr,"cilk_io_init failed\n");
    exit(1);
  }

  int socketID;
  long j;
  int i;
  int arr[NUM_SERVERS];
  int* sockIDs = initReduce();

  my_timer_t t;
  TIMER_START(t);

  // Currently it only works if cilk_read/writes are within a cilk_spawn
  cilk_spawn distPfib(n, sockIDs, &j);
  TIMER_STOP(t);
  printf("computed distFib of %d\treturned: %lu\ttime: %4f\n", n, j, TIMER_EVAL(t));

  return 0;
}
示例#7
0
void generate_level(Level *lvl, char *id) {
	LevelGeneratorFunc func = NULL;
	unsigned i;
	clock_t t;
	
	/* If 'id' is null, go with the default: */
	if(!id) id = GENERATOR_LIST[0].id;
	
	/* Look for the id: */
	for(i=0; GENERATOR_LIST[i].id; i++) {
		if(!strcmp(id, GENERATOR_LIST[i].id)) {
			gamelib_print("Using level generator: '%s'\n", GENERATOR_LIST[i].id);
			func = GENERATOR_LIST[i].gen;
			goto generate_level;
		}
	}
	
	/* Report what level generator we found: */
	gamelib_print("Couldn't find level generator: '%s'\n", id);
	gamelib_print("Using default level generator: '%s'\n", GENERATOR_LIST[0].id);
	
	/* If we didn't find the id, then we select the default: */
	if(!func) func = GENERATOR_LIST[0].gen;
	
generate_level:

	TIMER_START(t);
	
	/* Ok, now generate the level: */
	func(lvl);
	
	gamelib_print("Level generated in: ");
	TIMER_STOP(t);
}
示例#8
0
void long_press_button_ontimer( struct long_press_button_state_t* state ) {
    static uint8_t button_state = BUTTON_OFF;

    uint8_t next_button_state = digitalRead( state->pin );

    if ((BUTTON_OFF == button_state) &&
            (BUTTON_ON  == next_button_state)) {
        // OFF -> ON
        TIMER_START( state->timer, state->threshold_time );
    }
    else if ((BUTTON_ON == button_state) &&
             (BUTTON_ON == next_button_state)) {
        // still pressing

        TIMER_TICK( state->timer );

        if (TIMER_FIRED( state->timer )) {
            state->callback();

            // fires again after state->threshold_time
            button_state = BUTTON_OFF;
            return;
        }
    }

    button_state = next_button_state;
}
示例#9
0
int
test_sbit_cache( btimer_t*  timer,
                 FT_Face    face,
                 void*      user_data )
{
  FTC_SBit  glyph;
  int       i, done = 0;


  FT_UNUSED( user_data );

  if ( !sbit_cache )
  {
    if ( FTC_SBitCache_New(cache_man, &sbit_cache) )
      return 0;
  }

  TIMER_START( timer );

  for ( i = 0; i < face->num_glyphs; i++ )
  {
    if ( !FTC_SBitCache_Lookup(sbit_cache, &font_type, i, &glyph, NULL) )
      done++;
  }

  TIMER_STOP( timer );

  return done;
}
示例#10
0
int
test_cmap_cache( btimer_t*  timer,
                 FT_Face    face,
                 void*      user_data )
{
  bcharset_t*  charset = (bcharset_t*)user_data;
  int          i, done = 0;


  FT_UNUSED( face );

  if ( !cmap_cache )
  {
    if ( FTC_CMapCache_New(cache_man, &cmap_cache) )
      return 0;
  }

  TIMER_START( timer );

  for ( i = 0; i < charset->size; i++ )
  {
    if ( FTC_CMapCache_Lookup( cmap_cache, font_type.face_id, 0, charset->code[i] ) )
      done++;
  }

  TIMER_STOP( timer );

  return done;
}
示例#11
0
int
test_get_cbox( btimer_t*  timer,
               FT_Face    face,
               void*      user_data )
{
  FT_Glyph  glyph;
  FT_BBox   bbox;
  int       i, done = 0;


  FT_UNUSED( user_data );

  for ( i = 0; i < face->num_glyphs; i++ )
  {
    if ( FT_Load_Glyph( face, i, load_flags ) )
      continue;

    if ( FT_Get_Glyph( face->glyph, &glyph ) )
      continue;

    TIMER_START( timer );
    FT_Glyph_Get_CBox( glyph, FT_GLYPH_BBOX_PIXELS, &bbox );
    TIMER_STOP( timer );

    FT_Done_Glyph( glyph );
    done++;
  }

  return done;
}
示例#12
0
  /**
	 * Tests inserting blob data as a stream
	 *
	 * @throws Exception
	 *             if an error occurs
	 */
  void BlobTest::testBlobInsert( Connection & c, bool asString )
  {
    TIMER_START( "Populating blob table" );
    pstmt.reset( conn->prepareStatement("INSERT INTO BLOBTEST(blobdata) VALUES (?)") );

    if ( asString )
    {
      sql::SQLString str;
      testBlobFile->readFile( const_cast<std::string&>(str.asStdString()) );

      pstmt->setString( 1, str );
      pstmt->execute();
    }
    else
    {
      std::fstream & bIn= testBlobFile->getStream();
      ASSERT( ! bIn.fail() );

      pstmt->setBlob( 1, & bIn );
      pstmt->execute();
    }
  TIMER_STOP("Populating blob table");
  pstmt->clearParameters();

  doRetrieval();
}
示例#13
0
uint32_t CFrontend::getDiseqcReply(const int timeout_ms) const
{
	struct dvb_diseqc_slave_reply reply;

	reply.timeout = timeout_ms;

	TIMER_START();

	if (fop(ioctl, FE_DISEQC_RECV_SLAVE_REPLY, &reply) < 0)
		return 0;

	TIMER_STOP();

	/* timeout */
	if (reply.msg_len == 0)
		return 1;

	switch (reply.msg[0]) {
	case 0xe4:	/* ok */
		return 0;
	case 0xe5:	/* invalid address or unknown command */
		return 1;
	case 0xe6:	/* parity error */
		return 1;
	case 0xe7:	/* contention flag mismatch */
		return 1;
	default:	/* unexpected reply */
		return 0;
	}
}
示例#14
0
/* save screenshot in bmp format, return true if success, or false */
bool CScreenShot::SaveBmp()
{
	TIMER_START();
	if(!OpenFile())
		return false;

	unsigned char hdr[14 + 40];
	unsigned int i = 0;
#define PUT32(x) hdr[i++] = ((x)&0xFF); hdr[i++] = (((x)>>8)&0xFF); hdr[i++] = (((x)>>16)&0xFF); hdr[i++] = (((x)>>24)&0xFF);
#define PUT16(x) hdr[i++] = ((x)&0xFF); hdr[i++] = (((x)>>8)&0xFF);
#define PUT8(x) hdr[i++] = ((x)&0xFF);
	PUT8('B'); PUT8('M');
	PUT32((((xres * yres) * 3 + 3) &~ 3) + 14 + 40);
	PUT16(0); PUT16(0); PUT32(14 + 40);
	PUT32(40); PUT32(xres); PUT32(yres);
	PUT16(1);
	PUT16(4*8); // bits
	PUT32(0); PUT32(0); PUT32(0); PUT32(0); PUT32(0); PUT32(0);
#undef PUT32
#undef PUT16
#undef PUT8
	fwrite(hdr, 1, i, fd);

	int y;
	for (y=yres-1; y>=0 ; y-=1) {
		fwrite(pixel_data+(y*xres*4),xres*4,1,fd);
	}
	fclose(fd);
	TIMER_STOP(filename.c_str());
	return true;

}
示例#15
0
TEST_F(Benchmark, EnvelopeEmptyAllocations)
{
    TIMER_START(1000000);
    Envelope *e = new Envelope();
    delete e;
    TIMER_END("zippylog.envelope.empty_allocations");
}
示例#16
0
TEST_F(Benchmark, EnvelopeEmptyCopyConstructor)
{
    Envelope empty;
    TIMER_START(1000000);
    Envelope e(empty);
    TIMER_END("zippylog.envelope.empty_copy_constructor");
}
示例#17
0
文件: App.c 项目: mcufans/xlink
void Delayms (uint32_t ms)
{
    TIMER_STOP();
    TIMER_START(ms * 1000);
    while (!TIMER_EXPIRED());
    TIMER_STOP();
}
示例#18
0
void irkit_http_loop() {
#ifdef USE_INTERNET
    // long poll
    if (TIMER_FIRED(polling_timer)) {
        TIMER_STOP(polling_timer);

        if (TIMER_RUNNING(suspend_polling_timer)) {
            // suspend GET /m for a while if we have received a POST /messages request from client
            // client is in wifi, we can ignore our server for a while
            TIMER_START(polling_timer, SUSPEND_GET_MESSAGES_INTERVAL);
        }
        else {
            int8_t result = irkit_httpclient_get_messages();
            if ( result < 0 ) {
                HTTPLOG_PRINTLN("!E3");
                // maybe time cures GS? (no it doesn't, let's hardware reset, software reset doesn't work here)
                // don't software reset AVR, because that cuts off serial logging (for debug purpose only)
                wifi_hardware_reset();
            }
            else {
                polling_cid = result;
            }
        }
    }

    if (TIMER_FIRED(suspend_polling_timer)) {
        TIMER_STOP(suspend_polling_timer);
    }
#endif
}
示例#19
0
static int8_t on_post_messages_request(int8_t cid, GSwifi::GSREQUESTSTATE state) {
    while (! gs.bufferEmpty()) {
        char letter = gs.bufferGet();
        parse_json( letter );
    }

    if (state == GSwifi::GSREQUESTSTATE_RECEIVED) {
        // should be xmitting or idle (xmit finished)
        if (IrCtrl.state == IR_WRITING) {
            HTTPLOG_PRINTLN("!E7");
            // invalid json
            gs.writeHead(cid, 400);
            gs.writeEnd();
        }
        else {
            gs.writeHead(cid, 200);
            gs.writeEnd();
        }
        ring_put( &commands, COMMAND_CLOSE );
        ring_put( &commands, cid );

#ifdef USE_INTERNET
        TIMER_START( suspend_polling_timer, SUSPEND_GET_MESSAGES_INTERVAL );
#endif
    }

    return 0;
}
示例#20
0
int
test_get_glyph( btimer_t*  timer,
                FT_Face    face,
                void*      user_data )
{
  FT_Glyph  glyph;
  int       i, done = 0;


  FT_UNUSED( user_data );

  for ( i = 0; i < face->num_glyphs; i++ )
  {
    if ( FT_Load_Glyph( face, i, load_flags ) )
      continue;

    TIMER_START( timer );
    if ( !FT_Get_Glyph( face->glyph, &glyph ) )
    {
      FT_Done_Glyph( glyph );
      done++;
    }
    TIMER_STOP( timer );
  }

  return done;
}
示例#21
0
void CFrontend::sendDiseqcCommand(const struct dvb_diseqc_master_cmd *cmd, const uint32_t ms)
{
	TIMER_START();

#if HAVE_DVB_API_VERSION >= 3
	if (fop(ioctl, FE_DISEQC_SEND_MASTER_CMD, cmd) == 0)
#else
	secCmdSequence sequence;
	secCommand command;

	sequence.miniCommand = SEC_MINI_NONE;
	sequence.continuousTone = currentToneMode;
	sequence.voltage = currentTransponder.polarization;
	command.type = SEC_CMDTYPE_DISEQC_RAW;
	command.u.diseqc.cmdtype	= cmd->msg[0];
	command.u.diseqc.addr	= cmd->msg[1];
	command.u.diseqc.cmd	= cmd->msg[2];
	command.u.diseqc.numParams	= cmd->msg_len - 3;
	for (int i=0; i < (cmd->msg_len - 3); i++)
		command.u.diseqc.params[i] = cmd->msg[3 + i];
	sequence.commands = &command;
	sequence.numCommands = 1;

	if (fop_sec(ioctl, SEC_SEND_SEQUENCE, sequence) == 0)
#endif
		usleep(1000 * ms);

	TIMER_STOP();
}
示例#22
0
extern ChainDatabase* chainDatabaseCreate(Chain** database, int databaseStart, 
    int databaseLen, int* cards, int cardsLen) {
    
    ChainDatabase* db = (ChainDatabase*) malloc(sizeof(struct ChainDatabase));
    
    TIMER_START("Creating database");
    
    db->database = database + databaseStart;
    db->databaseStart = databaseStart;
    db->databaseLen = databaseLen;
    
    int i;
    long databaseElems = 0;
    for (i = 0; i < databaseLen; ++i) {
        databaseElems += chainGetLength(db->database[i]);
    }
    db->databaseElems = databaseElems;
    
    db->chainDatabaseGpu = chainDatabaseGpuCreate(db->database, databaseLen, 
        cards, cardsLen);
    
    TIMER_STOP;
    
    return db;
}
示例#23
0
文件: mandelbrot.c 项目: z88dk/z88dk
int main (int argc, char **argv)
{
    STATIC int w, h, bit_num;
    STATIC unsigned char byte_acc;
    STATIC int i;
	 STATIC int iter = 50;
    STATIC double x, y;
    STATIC double Zr, Zi, Cr, Ci, Tr, Ti;
    STATIC double limit = 2.0;

#ifdef COMMAND
    w = argc > 1 ? atoi(argv[1]) : 60;
	 h = argc > 2 ? atoi(argv[2]) : w;
#else
    w = h = 60;
#endif

    PRINTF3("P4\n%d %d\n",w,h);

TIMER_START();

    for(y=0;y<h;++y) 
    {
        for(x=0;x<w;++x)
        {
            Zr = Zi = Tr = Ti = 0.0;
            Cr = (2.0*x/w - 1.5); Ci=(2.0*y/h - 1.0);
        
            for (i=0;i<iter && (Tr+Ti <= limit*limit);++i)
            {
                Zi = 2.0*Zr*Zi + Ci;
                Zr = Tr - Ti + Cr;
                Tr = Zr * Zr;
                Ti = Zi * Zi;
            }
       
            byte_acc <<= 1; 
            if(Tr+Ti <= limit*limit) byte_acc |= 0x01;
                
            ++bit_num; 

            if(bit_num == 8)
            {
                PUTC(byte_acc,stdout);
                byte_acc = 0;
                bit_num = 0;
            }
            else if(x == w-1)
            {
                byte_acc <<= (8-w%8);
                PUTC(byte_acc,stdout);
                byte_acc = 0;
                bit_num = 0;
            }
        }
    }

TIMER_STOP();
}
示例#24
0
TEST_F(Benchmark, EnvelopeEmptyZmqProtocolSerialize)
{
    Envelope e;
    ::zmq::message_t msg;
    TIMER_START(1000000);
    e.ToProtocolZmqMessage(msg);
    TIMER_END("zippylog.envelope.empty_zmq_protocol_serialize");
}
示例#25
0
TEST_F(Benchmark, EnvelopeEmptySerialize)
{
    Envelope e;
    string s;
    TIMER_START(1000000);
    e.Serialize(s);
    TIMER_END("zippylog.envelope.empty_serialize");
}
示例#26
0
ProblemDescription::ProblemDescription() :
    goalset( NULL ),
    use_goalset( false ),
    is_covariant( false ),
    doing_covariant( false )
{
    TIMER_START( "total" );
}
示例#27
0
文件: sort.c 项目: z88dk/z88dk
void perform_sort(void)
{
TIMER_START();

   qsort(numbers, NUM, sizeof(int), ascending_order);

TIMER_STOP();
}
示例#28
0
TEST_F(Benchmark, EnvelopeEmptyConstructFromZmq)
{
    Envelope empty;
    ::zmq::message_t msg;
    empty.ToZmqMessage(msg);
    TIMER_START(1000000);
    Envelope e(msg);
    TIMER_END("zippylog.envelope.empty.construct_from_zmq");
}
示例#29
0
TEST_F(Benchmark, EnvelopeEmptyConstructFromString)
{
    Envelope empty;
    string serialized;
    empty.Serialize(serialized);
    TIMER_START(1000000);
    Envelope e(serialized);
    TIMER_END("zippylog.envelope.empty_construct_from_string");
}
示例#30
0
/* save screenshot in jpg format, return true if success, or false */
bool CScreenShot::SaveJpg()
{
	int quality = 90;

	TIMER_START();
	if(!OpenFile())
		return false;

	for (int y = 0; y < yres; y++) {
		int xres1 = y*xres*3;
		int xres2 = xres1+2;
		for (int x = 0; x < xres; x++) {
			int x2 = x*3;
			memcpy(pixel_data + x2 + xres1, pixel_data + x*4 + y*xres*4, 3);
			SWAP(pixel_data[x2 + xres1], pixel_data[x2 + xres2]);
		}
	}

	struct jpeg_compress_struct cinfo;
	struct my_error_mgr jerr;
	JSAMPROW row_pointer[1];
	unsigned int row_stride;

	cinfo.err = jpeg_std_error(&jerr.pub);
	jerr.pub.error_exit = my_error_exit;

	if (setjmp(jerr.setjmp_buffer)) {
		printf("CScreenShot::SaveJpg: %s save error\n", filename.c_str());
		jpeg_destroy_compress(&cinfo);
		fclose(fd);
		return false;
	}

	jpeg_create_compress(&cinfo);
	jpeg_stdio_dest(&cinfo, fd);

	cinfo.image_width = xres;
	cinfo.image_height = yres;
	cinfo.input_components = 3;
	cinfo.in_color_space = JCS_RGB;
	cinfo.dct_method = JDCT_IFAST;

	jpeg_set_defaults(&cinfo);
	jpeg_set_quality(&cinfo, quality, TRUE);
	jpeg_start_compress(&cinfo, TRUE);
	row_stride = xres * 3;

	while (cinfo.next_scanline < cinfo.image_height) {
		row_pointer[0] = & pixel_data[cinfo.next_scanline * row_stride];
		jpeg_write_scanlines(&cinfo, row_pointer, 1);
	}
	jpeg_finish_compress(&cinfo);
	jpeg_destroy_compress(&cinfo);
	fclose(fd);
	TIMER_STOP(filename.c_str());
	return true;
}