utils/bench-packets.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Mon, 25 Aug 2008 15:21:01 -0700
changeset 3553 065488d0420c
parent 3365 6409d2460601
child 3750 79a21524565f
permissions -rw-r--r--
bug 279: Packets need metadata support for printing without header checking
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
150
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
12
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
/*
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
 * Copyright (c) 2006 INRIA
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
 *
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
 *
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
 * GNU General Public License for more details.
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
 *
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
 *
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
 */
832
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    20
#include "ns3/system-wall-clock-ms.h"
14
6dd7d31c6fc3 replace yans include with ns3 include
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 12
diff changeset
    21
#include "ns3/packet.h"
882
777fcfabc1c8 rename packet-history.h to packet-metadata.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 881
diff changeset
    22
#include "ns3/packet-metadata.h"
12
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
#include <iostream>
832
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    24
#include <sstream>
3051
399d3858d190 avoid stupid string allocation all the time.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2877
diff changeset
    25
#include <string>
3365
6409d2460601 bug 245: build failure with gcc 4.3.x
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3208
diff changeset
    26
#include <stdlib.h> // for exit ()
12
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
16
99e833adbb46 change yans namespace to ns3
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 14
diff changeset
    28
using namespace ns3;
12
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
832
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    30
template <int N>
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    31
class BenchHeader : public Header
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    32
{
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    33
public:
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    34
  BenchHeader ();
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    35
  bool IsOk (void) const;
1322
b6a4885a92df re-enable packet benchmarking
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 894
diff changeset
    36
2643
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1869
diff changeset
    37
  static TypeId GetTypeId (void);
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1869
diff changeset
    38
  virtual TypeId GetInstanceTypeId (void) const;
2646
c1fef7686472 remove dead code.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2643
diff changeset
    39
  virtual void Print (std::ostream &os) const;
2643
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1869
diff changeset
    40
  virtual uint32_t GetSerializedSize (void) const;
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1869
diff changeset
    41
  virtual void Serialize (Buffer::Iterator start) const;
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1869
diff changeset
    42
  virtual uint32_t Deserialize (Buffer::Iterator start);
832
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    43
private:
3051
399d3858d190 avoid stupid string allocation all the time.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2877
diff changeset
    44
  static std::string GetTypeName (void);
832
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    45
  bool m_ok;
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    46
};
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    47
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    48
template <int N>
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    49
BenchHeader<N>::BenchHeader ()
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    50
  : m_ok (false)
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    51
{}
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    52
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    53
template <int N>
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    54
bool 
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    55
BenchHeader<N>::IsOk (void) const
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    56
{
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    57
  return m_ok;
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    58
}
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    59
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    60
template <int N>
3051
399d3858d190 avoid stupid string allocation all the time.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2877
diff changeset
    61
std::string 
399d3858d190 avoid stupid string allocation all the time.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2877
diff changeset
    62
BenchHeader<N>::GetTypeName (void)
399d3858d190 avoid stupid string allocation all the time.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2877
diff changeset
    63
{
399d3858d190 avoid stupid string allocation all the time.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2877
diff changeset
    64
  std::ostringstream oss;
399d3858d190 avoid stupid string allocation all the time.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2877
diff changeset
    65
  oss << "ns3::BenchHeader<" << N << ">";
399d3858d190 avoid stupid string allocation all the time.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2877
diff changeset
    66
  return oss.str ();
399d3858d190 avoid stupid string allocation all the time.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2877
diff changeset
    67
}
399d3858d190 avoid stupid string allocation all the time.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2877
diff changeset
    68
399d3858d190 avoid stupid string allocation all the time.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2877
diff changeset
    69
template <int N>
2643
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1869
diff changeset
    70
TypeId 
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1869
diff changeset
    71
BenchHeader<N>::GetTypeId (void)
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1869
diff changeset
    72
{
3051
399d3858d190 avoid stupid string allocation all the time.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2877
diff changeset
    73
  static TypeId tid = TypeId (GetTypeName ().c_str ())
2643
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1869
diff changeset
    74
    .SetParent<Header> ()
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1869
diff changeset
    75
    ;
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1869
diff changeset
    76
  return tid;
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1869
diff changeset
    77
}
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1869
diff changeset
    78
template <int N>
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1869
diff changeset
    79
TypeId 
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1869
diff changeset
    80
BenchHeader<N>::GetInstanceTypeId (void) const
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1869
diff changeset
    81
{
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1869
diff changeset
    82
  return GetTypeId ();
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1869
diff changeset
    83
}
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1869
diff changeset
    84
2a3324f4dabe define a TypeId for each Header/Trailer.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1869
diff changeset
    85
template <int N>
832
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    86
void 
1322
b6a4885a92df re-enable packet benchmarking
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 894
diff changeset
    87
BenchHeader<N>::Print (std::ostream &os) const
832
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    88
{
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    89
  NS_ASSERT (false);
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    90
}
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    91
template <int N>
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    92
uint32_t 
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    93
BenchHeader<N>::GetSerializedSize (void) const
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    94
{
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    95
  return N;
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    96
}
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    97
template <int N>
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
    98
void 
1322
b6a4885a92df re-enable packet benchmarking
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 894
diff changeset
    99
BenchHeader<N>::Serialize (Buffer::Iterator start) const
832
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   100
{
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   101
  start.WriteU8 (N, N);
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   102
}
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   103
template <int N>
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   104
uint32_t
1322
b6a4885a92df re-enable packet benchmarking
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 894
diff changeset
   105
BenchHeader<N>::Deserialize (Buffer::Iterator start)
832
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   106
{
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   107
  m_ok = true;
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   108
  for (int i = 0; i < N; i++)
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   109
    {
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   110
      if (start.ReadU8 () != N)
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   111
        {
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   112
          m_ok = false;
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   113
        }
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   114
    }
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   115
  return N;
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   116
}
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   117
3058
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   118
template <int N>
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   119
class BenchTag : public Tag
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   120
{
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   121
public:
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   122
  static std::string GetName (void) {
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   123
    std::ostringstream oss;
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   124
    oss << "anon::BenchTag<" << N << ">";
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   125
    return oss.str ();
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   126
  }
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   127
  static TypeId GetTypeId (void) {
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   128
    static TypeId tid = TypeId (GetName ().c_str ())
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   129
      .SetParent<Tag> ()
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   130
      .AddConstructor<BenchTag > ()
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   131
      .HideFromDocumentation ()
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   132
      ;
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   133
    return tid;
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   134
  }
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   135
  virtual TypeId GetInstanceTypeId (void) const {
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   136
    return GetTypeId ();
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   137
  }
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   138
  virtual uint32_t GetSerializedSize (void) const {
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   139
    return N;
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   140
  }
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   141
  virtual void Serialize (TagBuffer buf) const {
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   142
    for (uint32_t i = 0; i < N; ++i)
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   143
      {
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   144
        buf.WriteU8 (N);
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   145
      }
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   146
  }
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   147
  virtual void Deserialize (TagBuffer buf) {
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   148
    for (uint32_t i = 0; i < N; ++i)
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   149
      {
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   150
        buf.ReadU8 ();
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   151
      }
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   152
  }
3208
1a754d09c4ba bug 200: Packet::PrintTags is not implemented.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3058
diff changeset
   153
  virtual void Print (std::ostream &os) const {
1a754d09c4ba bug 200: Packet::PrintTags is not implemented.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3058
diff changeset
   154
    os << "N=" << N;
1a754d09c4ba bug 200: Packet::PrintTags is not implemented.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3058
diff changeset
   155
  }
3058
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   156
  BenchTag ()
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   157
    : Tag () {}
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   158
};
832
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   159
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   160
12
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   161
static void 
3058
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   162
benchD (uint32_t n)
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   163
{
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   164
  BenchHeader<25> ipv4;
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   165
  BenchHeader<8> udp;
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   166
  BenchTag<16> tag1;
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   167
  BenchTag<17> tag2;
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   168
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   169
  for (uint32_t i = 0; i < n; i++) {
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   170
    Ptr<Packet> p = Create<Packet> (2000);
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   171
    p->AddTag (tag1);
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   172
    p->AddHeader (udp);
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   173
    p->FindFirstMatchingTag (tag1);
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   174
    p->AddTag (tag2);
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   175
    p->AddHeader (ipv4);
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   176
    Ptr<Packet> o = p->Copy ();
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   177
    o->RemoveHeader (ipv4);
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   178
    p->FindFirstMatchingTag (tag2);
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   179
    o->RemoveHeader (udp);
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   180
  }
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   181
}
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   182
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   183
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   184
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   185
static void 
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   186
benchA (uint32_t n)
12
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   187
{
832
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   188
  BenchHeader<25> ipv4;
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   189
  BenchHeader<8> udp;
12
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   190
150
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
   191
  for (uint32_t i = 0; i < n; i++) {
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1323
diff changeset
   192
    Ptr<Packet> p = Create<Packet> (2000);
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1323
diff changeset
   193
    p->AddHeader (udp);
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1323
diff changeset
   194
    p->AddHeader (ipv4);
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1323
diff changeset
   195
    Ptr<Packet> o = p->Copy ();
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1323
diff changeset
   196
    o->RemoveHeader (ipv4);
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1323
diff changeset
   197
    o->RemoveHeader (udp);
150
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
   198
  }
12
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   199
}
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   200
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   201
static void 
3058
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   202
benchB (uint32_t n)
12
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   203
{
832
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   204
  BenchHeader<25> ipv4;
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   205
  BenchHeader<8> udp;
12
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   206
150
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
   207
  for (uint32_t i = 0; i < n; i++) {
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1323
diff changeset
   208
    Ptr<Packet> p = Create<Packet> (2000);
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1323
diff changeset
   209
    p->AddHeader (udp);
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1323
diff changeset
   210
    p->AddHeader (ipv4);
150
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
   211
  }
12
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   212
}
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   213
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   214
static void
3058
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   215
C2 (Ptr<Packet> p)
12
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   216
{
832
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   217
  BenchHeader<8> udp;
12
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   218
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1323
diff changeset
   219
  p->RemoveHeader (udp);
12
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   220
}
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   221
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   222
static void 
3058
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   223
C1 (Ptr<Packet> p)
12
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   224
{
832
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   225
  BenchHeader<25> ipv4;
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1323
diff changeset
   226
  p->RemoveHeader (ipv4);
3058
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   227
  C2 (p);
12
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   228
}
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   229
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   230
static void
3058
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   231
benchC (uint32_t n)
12
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   232
{
832
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   233
  BenchHeader<25> ipv4;
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   234
  BenchHeader<8> udp;
12
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   235
150
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
   236
  for (uint32_t i = 0; i < n; i++) {
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1323
diff changeset
   237
    Ptr<Packet> p = Create<Packet> (2000);
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1323
diff changeset
   238
    p->AddHeader (udp);
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1323
diff changeset
   239
    p->AddHeader (ipv4);
3058
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   240
    C1 (p);
150
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
   241
  }
12
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   242
}
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   243
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   244
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   245
static void
53
ae406f4957d5 variable/method/function coding style update
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 16
diff changeset
   246
runBench (void (*bench) (uint32_t), uint32_t n, char const *name)
12
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   247
{
832
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   248
  SystemWallClockMs time;
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   249
  time.Start ();
150
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
   250
  (*bench) (n);
832
3d1243d770d9 fix the packet benchmark and enable it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 150
diff changeset
   251
  unsigned long long deltaMs = time.End ();
150
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
   252
  double ps = n;
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
   253
  ps *= 1000;
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
   254
  ps /= deltaMs;
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
   255
  std::cout << name<<"=" << ps << " packets/s" << std::endl;
12
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   256
}
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   257
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   258
int main (int argc, char *argv[])
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   259
{
150
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
   260
  uint32_t n = 0;
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
   261
  while (argc > 0) {
833
224bfad58818 a bunch of optimizations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 832
diff changeset
   262
      if (strncmp ("--n=", argv[0],strlen ("--n=")) == 0) 
224bfad58818 a bunch of optimizations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 832
diff changeset
   263
        {
150
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
   264
          char const *nAscii = argv[0] + strlen ("--n=");
3365
6409d2460601 bug 245: build failure with gcc 4.3.x
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3208
diff changeset
   265
          std::istringstream iss;
6409d2460601 bug 245: build failure with gcc 4.3.x
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3208
diff changeset
   266
          iss.str (nAscii);
6409d2460601 bug 245: build failure with gcc 4.3.x
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3208
diff changeset
   267
          iss >> n;
833
224bfad58818 a bunch of optimizations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 832
diff changeset
   268
        }
150
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
   269
      argc--;
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
   270
      argv++;
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
   271
  }
1814
21c9c4dd9768 update bench-packets.cc program
Tom Henderson <tomh@tomh.org>
parents: 1323
diff changeset
   272
  if (n == 0)
21c9c4dd9768 update bench-packets.cc program
Tom Henderson <tomh@tomh.org>
parents: 1323
diff changeset
   273
    {
21c9c4dd9768 update bench-packets.cc program
Tom Henderson <tomh@tomh.org>
parents: 1323
diff changeset
   274
      std::cerr << "Error-- number of packets must be specified " <<
21c9c4dd9768 update bench-packets.cc program
Tom Henderson <tomh@tomh.org>
parents: 1323
diff changeset
   275
        "by command-line argument --n=(number of packets)" << std::endl;
21c9c4dd9768 update bench-packets.cc program
Tom Henderson <tomh@tomh.org>
parents: 1323
diff changeset
   276
      exit (1);
21c9c4dd9768 update bench-packets.cc program
Tom Henderson <tomh@tomh.org>
parents: 1323
diff changeset
   277
    }
21c9c4dd9768 update bench-packets.cc program
Tom Henderson <tomh@tomh.org>
parents: 1323
diff changeset
   278
  std::cout << "Running bench-packets with n=" << n << std::endl;
12
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   279
3058
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   280
  runBench (&benchA, n, "a");
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   281
  runBench (&benchB, n, "b");
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   282
  runBench (&benchC, n, "c");
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   283
  runBench (&benchD, n, "d");
894
d6715af78f7e update packet benchmark
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 884
diff changeset
   284
3553
065488d0420c bug 279: Packets need metadata support for printing without header checking
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3365
diff changeset
   285
  Packet::EnablePrinting ();
3058
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   286
  runBench (&benchA, n, "meta-a");
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   287
  runBench (&benchB, n, "meta-b");
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   288
  runBench (&benchC, n, "meta-c");
31e4703e08da bench tags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3054
diff changeset
   289
  runBench (&benchD, n, "meta-d");
894
d6715af78f7e update packet benchmark
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 884
diff changeset
   290
12
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   291
3054
b152a62d2017 enable metadata only on second run
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 3051
diff changeset
   292
150
663120712cd9 fix coding style
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 131
diff changeset
   293
  return 0;
12
917ba023c576 utils and samples
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   294
}