Skip to content

Instantly share code, notes, and snippets.

@NanXiao
Created January 28, 2020 08:43
Show Gist options
  • Save NanXiao/7d515bb4a28396ca4aab0422cfe55c2a to your computer and use it in GitHub Desktop.
Save NanXiao/7d515bb4a28396ca4aab0422cfe55c2a to your computer and use it in GitHub Desktop.
#!/usr/bin/awk -f
BEGIN {
FS = ",";
records_have_session_id = 0;
session_resumption_use_id = 0;
records_have_session_ticket = 0;
session_resumption_use_ticket = 0;
}
{
if (length($1) != 0 || length($2) != 0)
{
records_have_session_id++;
if ($1 == $2)
{
session_resumption_use_id++;
}
}
if (length($3) != 0 || length($4) != 0)
{
records_have_session_ticket++;
if (length($3) != 0)
{
session_ticket_array[$3]++;
}
if (length($4) != 0)
{
session_ticket_array[$4]++;
}
}
}
END {
printf "total_record_num=%d\n", NR;
printf "\n";
printf "records_have_session_id=%d\n", records_have_session_id;
printf "records_have_session_id ratio=%f\n", records_have_session_id / NR;
printf "\n";
printf "session_resumption_use_id=%d\n", session_resumption_use_id;
printf "session_resumption_use_id ratio=%f\n", session_resumption_use_id / NR;
printf "\n";
printf "records_have_session_ticket=%d\n", records_have_session_ticket;
printf "records_have_session_ticket ratio=%f\n", records_have_session_ticket / NR;
printf "\n";
for (session_ticket in session_ticket_array)
{
if (session_ticket_array[session_ticket] > 1)
{
session_resumption_use_ticket++;
}
}
printf "session_resumption_use_ticket=%d\n", session_resumption_use_ticket;
printf "session_resumption_use_ticket ratio=%f\n", session_resumption_use_ticket / NR;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment