~ubuntu-branches/ubuntu/maverick/zeromq/maverick

« back to all changes in this revision

Viewing changes to perf/java/local_lat.java

  • Committer: Bazaar Package Importer
  • Author(s): Adrian von Bidder
  • Date: 2010-03-17 10:43:40 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100317104340-un1ne0oqe16w8eaq
Tags: 2.0.6beta.dfsg-1
* New upstream version.
  - Source doesn't include non-C/C++ language bindings anymore.
  - New versioning: 2.0.6 is official upstream version which is a beta.
* Repacked orig tar: removed non-free RFC documents (closes: #567513)
* Improved/corrected description and copyright file, added bzip2 build
  dependency.  Thanks to feedback from zeromq mailing list.
* Disable OpenPGM on non-x86 architectures (closes: #567848)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    Copyright (c) 2007-2010 iMatix Corporation
3
 
 
4
 
    This file is part of 0MQ.
5
 
 
6
 
    0MQ is free software; you can redistribute it and/or modify it under
7
 
    the terms of the Lesser GNU General Public License as published by
8
 
    the Free Software Foundation; either version 3 of the License, or
9
 
    (at your option) any later version.
10
 
 
11
 
    0MQ is distributed in the hope that it will be useful,
12
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
    Lesser GNU General Public License for more details.
15
 
 
16
 
    You should have received a copy of the Lesser GNU General Public License
17
 
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 
*/
19
 
 
20
 
import org.zmq.*;
21
 
 
22
 
class local_lat
23
 
{
24
 
     public static void main (String [] args)
25
 
     {
26
 
         if (args.length != 3) {
27
 
             System.out.println ("usage: local_lat <bind-to> " +
28
 
                 "<message-size> <roundtrip-count>");
29
 
             return;
30
 
         }
31
 
 
32
 
         String bindTo = args [0];
33
 
         int messageSize = Integer.parseInt (args [1]);
34
 
         int roundtripCount = Integer.parseInt (args [2]);
35
 
 
36
 
         org.zmq.Context ctx = new org.zmq.Context (1, 1, 0);
37
 
 
38
 
         org.zmq.Socket s = new org.zmq.Socket (ctx, org.zmq.Socket.REP);
39
 
         s.bind (bindTo);
40
 
 
41
 
         for (int i = 0; i != roundtripCount; i++) {
42
 
             byte [] data = s.recv (0);
43
 
             assert (data.length == messageSize);
44
 
             s.send (data, 0);
45
 
         }
46
 
 
47
 
         try {
48
 
             Thread.sleep (1000);
49
 
         }
50
 
         catch (InterruptedException e) {
51
 
             e.printStackTrace ();
52
 
         }
53
 
 
54
 
     }
55
 
}