Re:A Little Story About the `yes` Unix Command
by dmitrygr on Wednesday October 11, 2017 @08:22PM
(#15454722)
not as readable as this faster variant
[ Parent
| on HN ]
Re:A Little Story About the `yes` Unix Command
by kibwen on Wednesday October 11, 2017 @09:12PM
(#15454932)
Bah, that'll never pass code review. How about this:
#include <sys/uio.h>
#define str(x) #x
#define expand(x) str(x)
#define y1 y\n
#define y2 expand(y1) expand(y1)
#define y4 y2 y2
#define y8 y4 y4
#define y16 y8 y8
#define y32 y16 y16
#define y64 y32 y32
#define y128 y64 y64
#define y256 y128 y128
#define y512 y256 y256
#define y1024 y512 y512
#define y2048 y1024 y1024
//2048 "y\n" s
static char __attribute__((aligned(4096))) str[] = y2048;
static struct iovec v[] = {
{str, 4096}, //adjust number of these to taste
{str, 4096},
{str, 4096},
{str, 4096},
{str, 4096},
{str, 4096},
{str, 4096},
{str, 4096},
{str, 4096},
{str, 4096},
{str, 4096},
{str, 4096},
{str, 4096},
{str, 4096},
{str, 4096},
{str, 4096},
};
int main(int argc, char** argv) {
while(1) {
//scatter-gather write (on linux there is basically no way for write to write an odd number of characters, except EOF, so we need not check for partial writes
(void)writev(1, v, sizeof(v) / sizeof(*v));
}
return 0;
}
Re:A Little Story About the `yes` Unix Command
by flukus on Wednesday October 11, 2017 @09:58PM
(#15455119)
Both suffer from way to much binary bloat, for small performance hit we can shave off a whole 4Kb.
Is anyone going to take a stab at an enterprise edition?
Re:A Little Story About the `yes` Unix Command
by int_19h on Thursday October 12, 2017 @02:40AM
(#15456089)
Here you go.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="3.0">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:call-template name="y"/>
</xsl:template>
<xsl:template name="y">
<xsl:text>y </xsl:text>
<xsl:call-template name="y"/>
</xsl:template>
</xsl:stylesheet>
Re:A Little Story About the `yes` Unix Command
by taneq on Wednesday October 11, 2017 @10:40PM
(#15455291)
"Enterprise edition" would be the same thing but written in Java and require an Oracle backend.
Re:A Little Story About the `yes` Unix Command
by _jal on Wednesday October 11, 2017 @11:07PM
(#15455384)
Don't forget LDAP, SAML and SNMP support. What's the OID for 'y' again?
Re:A Little Story About the `yes` Unix Command
by anonfunction on Thursday October 12, 2017 @12:58AM
(#15455771)
Re:A Little Story About the `yes` Unix Command
by viraptor on Thursday October 12, 2017 @01:26AM
(#15455863)
Could reuse type from 2.16.840.1.113883.18.347. It's an extended yes/no, to account for "flavours of null". (Not even joking...)