xref: /illumos-gate/usr/src/cmd/dtrace/test/tst/common/aggs/tst.keysort.d (revision 581cede61ac9c14d8d4ea452562a567189eead78)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #pragma D option quiet
30 
31 BEGIN
32 {
33 	i = 0;
34 	j = 0;
35 
36 	@tour["Ghent", i++, j] = sum(5 - j);
37 	j++;
38 
39 	@tour["Berlin", i++, j] = sum(5 - j);
40 	j++;
41 
42 	@tour["London", i++, j] = sum(5 - j);
43 	@tour["Dublin", i++, j] = sum(5 - j);
44 	j++;
45 
46 	@tour["Shanghai", i++, j] = sum(5 - j);
47 	j++;
48 
49 	@tour["Zurich", i++, j] = sum(5 - j);
50 	j++;
51 
52 	@tour["Regina", i++, j] = sum(5 - j);
53 	@tour["Winnipeg", i++, j] = sum(5 - j);
54 	@tour["Edmonton", i++, j] = sum(5 - j);
55 	@tour["Calgary", i++, j] = sum(5 - j);
56 	@tour["Vancouver", i++, j] = sum(5 - j);
57 	@tour["Victoria", i++, j] = sum(5 - j);
58 	j++;
59 
60 	@tour["Prague", i++, j] = sum(5 - j);
61 	@tour["London", i++, j] = sum(5 - j);
62 	j++;
63 
64 	@tour["Brisbane", i++, j] = sum(5 - j);
65 	@tour["Sydney", i++, j] = sum(5 - j);
66 	@tour["Melbourne", i++, j] = sum(5 - j);
67 	j++;
68 
69 	setopt("aggsortkey", "false");
70 	setopt("aggsortkeypos", "0");
71 	@tour["Amsterdam", i++, j] = sum(5 - j);
72 
73 	printf("By value:\n");
74 	printa("%20s %8d %8d %8@d\n", @tour);
75 
76 	setopt("aggsortkey");
77 	printf("\nBy key, position 0:\n");
78 	printa("%20s %8d %8d %8@d\n", @tour);
79 
80 	setopt("aggsortkeypos", "1");
81 	printf("\nBy key, position 1:\n");
82 	printa("%20s %8d %8d %8@d\n", @tour);
83 
84 	setopt("aggsortkeypos", "2");
85 	printf("\nBy key, position 2:\n");
86 	printa("%20s %8d %8d %8@d\n", @tour);
87 
88 	setopt("aggsortkey", "false");
89 	setopt("aggsortkeypos", "0");
90 	setopt("aggsortrev");
91 
92 	printf("\nReversed by value:\n");
93 	printa("%20s %8d %8d %8@d\n", @tour);
94 
95 	setopt("aggsortkey");
96 	printf("\nReversed by key, position 0:\n");
97 	printa("%20s %8d %8d %8@d\n", @tour);
98 
99 	setopt("aggsortkeypos", "1");
100 	printf("\nReversed by key, position 1:\n");
101 	printa("%20s %8d %8d %8@d\n", @tour);
102 
103 	setopt("aggsortkeypos", "2");
104 	printf("\nReversed by key, position 2:\n");
105 	printa("%20s %8d %8d %8@d\n", @tour);
106 
107 	exit(0);
108 }
109