本文整理汇总了C++中reset_stats函数的典型用法代码示例。如果您正苦于以下问题:C++ reset_stats函数的具体用法?C++ reset_stats怎么用?C++ reset_stats使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了reset_stats函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read_stats
/* Renvoie 'a' le nombres de parties,
'b' le nombre de victoires,
'c' le nombre de victoires sans aide */
void read_stats (char data[3][6]) {
FILE *f_stats = fopen("DATA", "r");
if (f_stats == NULL) {
strcpy(data[0], "0");
strcpy(data[1], "0");
strcpy(data[2], "0");
reset_stats();
return;
}
int i = 0;
int l = 0;
char c = (char)fgetc(f_stats);
while (!feof(f_stats)) {
if (l < 5 && strchr("0123456789", (int)c)) {
data[i][l] = c;
data[i][l+1] = '\0';
l++;
} else if (i < 2 && c == ' ') {
i++;
l = 0;
} else if (!(i == 2 && c == '\n')) {
fclose(f_stats);
reset_stats();
strcpy(data[0], "0");
strcpy(data[1], "0");
strcpy(data[2], "0");
return;
}
c = (char)fgetc(f_stats);
}
fclose(f_stats);
}
示例2: basic_audio_stream
static void basic_audio_stream() {
AudioStream * marielle = audio_stream_new (MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT,FALSE);
stats_t marielle_stats;
AudioStream * margaux = audio_stream_new (MARGAUX_RTP_PORT,MARGAUX_RTCP_PORT, FALSE);
stats_t margaux_stats;
RtpProfile* profile = rtp_profile_new("default profile");
reset_stats(&marielle_stats);
reset_stats(&margaux_stats);
rtp_profile_set_payload (profile,0,&payload_type_pcmu8000);
CU_ASSERT_EQUAL(audio_stream_start_full(margaux
, profile
, MARIELLE_IP
, MARIELLE_RTP_PORT
, MARIELLE_IP
, MARIELLE_RTCP_PORT
, 0
, 50
, NULL
, RECORDED_8K_1S_FILE
, NULL
, NULL
, 0),0);
CU_ASSERT_EQUAL(audio_stream_start_full(marielle
, profile
, MARGAUX_IP
, MARGAUX_RTP_PORT
, MARGAUX_IP
, MARGAUX_RTCP_PORT
, 0
, 50
, HELLO_8K_1S_FILE
, NULL
, NULL
, NULL
, 0),0);
ms_filter_add_notify_callback(marielle->soundread, notify_cb, &marielle_stats,TRUE);
CU_ASSERT_TRUE(wait_for_until(&marielle->ms,&margaux->ms,&marielle_stats.number_of_EndOfFile,1,12000));
audio_stream_get_local_rtp_stats(marielle,&marielle_stats.rtp);
audio_stream_get_local_rtp_stats(margaux,&margaux_stats.rtp);
/* No packet loss is assumed */
CU_ASSERT_EQUAL(marielle_stats.rtp.sent,margaux_stats.rtp.recv);
audio_stream_stop(marielle);
audio_stream_stop(margaux);
unlink(RECORDED_8K_1S_FILE);
}
示例3: reset_stats
Cache::Cache(Storage* s)
{
storage = s;
reset_stats();
blocksize = 1 << 10; // 1KB
memorysize = 1 << 20; // 1MB
}
示例4: virtio_balloon_stat
static void virtio_balloon_stat(void *opaque, MonitorCompletion cb,
void *cb_data)
{
VirtIOBalloon *dev = opaque;
/* For now, only allow one request at a time. This restriction can be
* removed later by queueing callback and data pairs.
*/
if (dev->stats_callback != NULL) {
return;
}
dev->stats_callback = cb;
dev->stats_opaque_callback_data = cb_data;
if (ENABLE_GUEST_STATS
&& (dev->vdev.guest_features & (1 << VIRTIO_BALLOON_F_STATS_VQ))) {
virtqueue_push(dev->svq, &dev->stats_vq_elem, dev->stats_vq_offset);
virtio_notify(&dev->vdev, dev->svq);
return;
}
/* Stats are not supported. Clear out any stale values that might
* have been set by a more featureful guest kernel.
*/
reset_stats(dev);
complete_stats_request(dev);
}
示例5: virtio_balloon_stat
static void virtio_balloon_stat(void *opaque, BalloonInfo *info)
{
VirtIOBalloon *dev = opaque;
#if 0
/* Disable guest-provided stats for now. For more details please check:
* https://bugzilla.redhat.com/show_bug.cgi?id=623903
*
* If you do enable it (which is probably not going to happen as we
* need a new command for it), remember that you also need to fill the
* appropriate members of the BalloonInfo structure so that the stats
* are returned to the client.
*/
if (dev->vdev.guest_features & (1 << VIRTIO_BALLOON_F_STATS_VQ)) {
virtqueue_push(dev->svq, &dev->stats_vq_elem, dev->stats_vq_offset);
virtio_notify(&dev->vdev, dev->svq);
return;
}
#endif
/* Stats are not supported. Clear out any stale values that might
* have been set by a more featureful guest kernel.
*/
reset_stats(dev);
info->actual = ram_size - ((uint64_t) dev->actual <<
VIRTIO_BALLOON_PFN_SHIFT);
}
示例6: calc_average
static void calc_average(PgStats *avg, PgStats *cur, PgStats *old)
{
uint64_t query_count;
uint64_t xact_count;
usec_t dur = get_cached_time() - old_stamp;
reset_stats(avg);
if (dur <= 0)
return;
query_count = cur->query_count - old->query_count;
xact_count = cur->xact_count - old->xact_count;
avg->query_count = USEC * query_count / dur;
avg->xact_count = USEC * xact_count / dur;
avg->client_bytes = USEC * (cur->client_bytes - old->client_bytes) / dur;
avg->server_bytes = USEC * (cur->server_bytes - old->server_bytes) / dur;
if (query_count > 0)
avg->query_time = (cur->query_time - old->query_time) / query_count;
if (xact_count > 0)
avg->xact_time = (cur->xact_time - old->xact_time) / xact_count;
avg->wait_time = USEC * (cur->wait_time - old->wait_time) / dur;
}
示例7: virtio_balloon_receive_stats
static void virtio_balloon_receive_stats(VirtIODevice *vdev, VirtQueue *vq)
{
VirtIOBalloon *s = DO_UPCAST(VirtIOBalloon, vdev, vdev);
VirtQueueElement *elem = &s->stats_vq_elem;
VirtIOBalloonStat stat;
size_t offset = 0;
if (!virtqueue_pop(vq, elem)) {
return;
}
/* Initialize the stats to get rid of any stale values. This is only
* needed to handle the case where a guest supports fewer stats than it
* used to (ie. it has booted into an old kernel).
*/
reset_stats(s);
while (iov_to_buf(elem->out_sg, elem->out_num, &stat, offset, sizeof(stat))
== sizeof(stat)) {
uint16_t tag = tswap16(stat.tag);
uint64_t val = tswap64(stat.val);
offset += sizeof(stat);
if (tag < VIRTIO_BALLOON_S_NR)
s->stats[tag] = val;
}
s->stats_vq_offset = offset;
complete_stats_request(s);
}
示例8: deepidle_init
static int __init deepidle_init(void)
{
int ret;
pr_info("%s misc_register(%s)\n", __FUNCTION__, deepidle_device.name);
ret = misc_register(&deepidle_device);
if (ret)
{
pr_err("%s misc_register(%s) fail\n", __FUNCTION__, deepidle_device.name);
return 1;
}
if (sysfs_create_group(&deepidle_device.this_device->kobj, &deepidle_group) < 0)
{
pr_err("%s sysfs_create_group fail\n", __FUNCTION__);
pr_err("Failed to create sysfs group for device (%s)!\n", deepidle_device.name);
}
mutex_lock(&lock);
reset_stats();
mutex_unlock(&lock);
return 0;
}
示例9: sizeof
VirtIODevice *virtio_balloon_init(DeviceState *dev)
{
VirtIOBalloon *s;
int ret;
s = (VirtIOBalloon *)virtio_common_init("virtio-balloon",
VIRTIO_ID_BALLOON,
8, sizeof(VirtIOBalloon));
s->vdev.get_config = virtio_balloon_get_config;
s->vdev.set_config = virtio_balloon_set_config;
s->vdev.get_features = virtio_balloon_get_features;
ret = qemu_add_balloon_handler(virtio_balloon_to_target,
virtio_balloon_stat, s);
if (ret < 0) {
virtio_cleanup(&s->vdev);
return NULL;
}
s->ivq = virtio_add_queue(&s->vdev, 128, virtio_balloon_handle_output);
s->dvq = virtio_add_queue(&s->vdev, 128, virtio_balloon_handle_output);
s->svq = virtio_add_queue(&s->vdev, 128, virtio_balloon_receive_stats);
reset_stats(s);
s->qdev = dev;
register_savevm(dev, "virtio-balloon", -1, 1,
virtio_balloon_save, virtio_balloon_load, s);
return &s->vdev;
}
示例10: virtio_balloon_device_realize
static void virtio_balloon_device_realize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VirtIOBalloon *s = VIRTIO_BALLOON(dev);
int ret;
virtio_init(vdev, "virtio-balloon", VIRTIO_ID_BALLOON,
sizeof(struct virtio_balloon_config));
ret = qemu_add_balloon_handler(virtio_balloon_to_target,
virtio_balloon_stat, s);
if (ret < 0) {
error_setg(errp, "Only one balloon device is supported");
virtio_cleanup(vdev);
return;
}
s->ivq = virtio_add_queue(vdev, 128, virtio_balloon_handle_output);
s->dvq = virtio_add_queue(vdev, 128, virtio_balloon_handle_output);
s->svq = virtio_add_queue(vdev, 128, virtio_balloon_receive_stats);
reset_stats(s);
register_savevm(dev, "virtio-balloon", -1, 1,
virtio_balloon_save, virtio_balloon_load, s);
object_property_add(OBJECT(dev), "guest-stats", "guest statistics",
balloon_stats_get_all, NULL, NULL, s, NULL);
object_property_add(OBJECT(dev), "guest-stats-polling-interval", "int",
balloon_stats_get_poll_interval,
balloon_stats_set_poll_interval,
NULL, s, NULL);
}
示例11: virtio_balloon_device_realize
static void virtio_balloon_device_realize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VirtIOBalloon *s = VIRTIO_BALLOON(dev);
int ret;
virtio_init(vdev, "virtio-balloon", VIRTIO_ID_BALLOON,
sizeof(struct virtio_balloon_config));
ret = qemu_add_balloon_handler(virtio_balloon_to_target,
virtio_balloon_stat, s);
if (ret < 0) {
error_setg(errp, "Only one balloon device is supported");
virtio_cleanup(vdev);
return;
}
s->ivq = virtio_add_queue(vdev, 128, virtio_balloon_handle_output);
s->dvq = virtio_add_queue(vdev, 128, virtio_balloon_handle_output);
s->svq = virtio_add_queue(vdev, 128, virtio_balloon_receive_stats);
reset_stats(s);
register_savevm(dev, "virtio-balloon", -1, 1,
virtio_balloon_save, virtio_balloon_load, s);
}
示例12: tick_empty_users
void tick_empty_users(gpointer key, User_stats * us, void *data) {
if (is_new_tick(us->tick)) {
us->tick = get_current_tick();
Stats stats_holder;
reset_stats(&stats_holder);
push_stats(&stats_holder, us);
}
}
示例13: mode_14_correct_answer
void mode_14_correct_answer() {
play_feedback(MP3_CORRECT);
speak_letters_in_word(mode_14_chosen_word);
speak_word(mode_14_chosen_word);
play_tada();
score++;
mode_14_play_stats();
reset_globals();
reset_stats();
}
示例14: process_effects
void Creature::process_turn()
{
process_effects();
// Call this in case any effects have changed our stats
reset_stats();
// add an appropriate number of moves
moves += get_speed();
}
示例15: create_text_stream
static void create_text_stream(text_stream_tester_t *tst, int payload_type) {
tst->ts = text_stream_new2(tst->local_ip, tst->local_rtp, tst->local_rtcp);
tst->local_rtp = rtp_session_get_local_port(tst->ts->ms.sessions.rtp_session);
tst->local_rtcp = rtp_session_get_local_rtcp_port(tst->ts->ms.sessions.rtp_session);
reset_stats(&tst->stats);
rtp_session_set_multicast_loopback(tst->ts->ms.sessions.rtp_session, TRUE);
tst->stats.q = ortp_ev_queue_new();
rtp_session_register_event_queue(tst->ts->ms.sessions.rtp_session, tst->stats.q);
tst->payload_type = payload_type;
}