(b *testing.B)
| 856 | } |
| 857 | |
| 858 | func BenchmarkEcho(b *testing.B) { |
| 859 | require.NoError(b, frankenphp.Init()) |
| 860 | b.Cleanup(frankenphp.Shutdown) |
| 861 | |
| 862 | cwd, _ := os.Getwd() |
| 863 | testDataDir := cwd + "/testdata/" |
| 864 | |
| 865 | opt := frankenphp.WithRequestDocumentRoot(testDataDir, false) |
| 866 | handler := func(w http.ResponseWriter, r *http.Request) { |
| 867 | req, err := frankenphp.NewRequestWithContext(r, opt) |
| 868 | require.NoError(b, err) |
| 869 | |
| 870 | require.NoError(b, frankenphp.ServeHTTP(w, req)) |
| 871 | } |
| 872 | |
| 873 | const body = `{ |
| 874 | "squadName": "Super hero squad", |
| 875 | "homeTown": "Metro City", |
| 876 | "formed": 2016, |
| 877 | "secretBase": "Super tower", |
| 878 | "active": true, |
| 879 | "members": [ |
| 880 | { |
| 881 | "name": "Molecule Man", |
| 882 | "age": 29, |
| 883 | "secretIdentity": "Dan Jukes", |
| 884 | "powers": ["Radiation resistance", "Turning tiny", "Radiation blast"] |
| 885 | }, |
| 886 | { |
| 887 | "name": "Madame Uppercut", |
| 888 | "age": 39, |
| 889 | "secretIdentity": "Jane Wilson", |
| 890 | "powers": [ |
| 891 | "Million tonne punch", |
| 892 | "Damage resistance", |
| 893 | "Superhuman reflexes" |
| 894 | ] |
| 895 | }, |
| 896 | { |
| 897 | "name": "Eternal Flame", |
| 898 | "age": 1000000, |
| 899 | "secretIdentity": "Unknown", |
| 900 | "powers": [ |
| 901 | "Immortality", |
| 902 | "Heat Immunity", |
| 903 | "Inferno", |
| 904 | "Teleportation", |
| 905 | "Interdimensional travel" |
| 906 | ] |
| 907 | } |
| 908 | ] |
| 909 | }` |
| 910 | |
| 911 | r := strings.NewReader(body) |
| 912 | req := httptest.NewRequest("POST", "http://example.com/echo.php", r) |
| 913 | w := httptest.NewRecorder() |
| 914 | |
| 915 | for b.Loop() { |
nothing calls this directly
no test coverage detected